CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2002
    Location
    London, UK
    Posts
    1,569

    Debugging a multithreaded DLL with STL

    (Also, submitted in VC++ forum)

    Hi everyone,

    I am debuggin an C++ app and am having some trouble with it.

    It is a multithreaded DLL, which makes use of the STL library. The program dies in apparently random places. Every time it fails the operating system reports an error


    Code:
    Runtime Error!
    
    Program: ...\C++_Caller_App\Caller.exe
    
    
    abnormal program termination
    Caller.exe is the calling application which calls my DLL. I have managed to identify that the problem is DEFINITELY in the DLL not the calling app, and have (to some degree) managed to isolate the portion of code giving the error. (Which is not easy because it seems to occur in different places, at different times)

    This error only occurs when I have complied the DLL in RELEASE configuration, never in DEBUG... which would usually make me think there was a memory leak from pointers or out-of-bounds arrays, but I am not using any of these. The only thing which I am using in that section of code is the STL "string" class. (I'm using STL version 3.3 for Silicon Graphics)

    Does any one have any idea what could be causing the error? And/Or how to fix it?

    P.S. I have finished writting the program and it is not small at all, so I can not afford to re-write it to use, say, MFC::CString (YUCK!!)

    Thanks
    Mike

  2. #2
    Join Date
    Dec 2002
    Posts
    287
    First, we would like to see some code.
    Second, did you apply all the pathches to the STL library (you can look at http://www.dinkumware.com/vc_fixes.html for more details) ? The string class is pretty buggy - reference counting doesn't work properly for mutithreaded apps.
    You can build a release version with symbols and try to use something like the old MSJExceptionHandler to get more information about the place the crash occurs:
    http://www.microsoft.com/msj/default...497/newnav.htm

    Dan

  3. #3
    Join Date
    Feb 2002
    Posts
    5,757
    Are there functions that return references to string objects. One solution is return the string by value.

    Kuphryn

  4. #4
    Join Date
    Dec 2002
    Posts
    287
    And why would this approach help ?

    Dan

  5. #5
    Join Date
    Nov 2000
    Location
    tokyo-jp.
    Posts
    314
    I had that problem when the library i am linking to is built with different code generation option. (when the library is built using debug multi threaded and my application is built using single threaded library).

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Debugging a multithreaded DLL with STL

    Originally posted by Pinky98
    (Also, submitted in VC++ forum)

    The only thing which I am using in that section of code is the STL "string" class. (I'm using STL version 3.3 for Silicon Graphics)
    This is confusing. VC++ comes with a string class from DinkumWare. What reasons made you use SGI's? And when you are using SGI's, how do you make sure you've totally "turned off" the VC++ string class so that you don't get conflicts with two different string classes running around? (I'm not saying it isn't possible -- I want to know just what steps you did to make sure this isn't happening)

    If you try to mix and match string classes, I can see where there would be random errors, especially if you try to pass any of these string objects to other functions. One function is built assuming std::string from Dinkumware, and you pass it a std::string from SGI. A crash is inevitable.

    Another thing, std::string is not guaranteed to be thread safe. If you use SGI, you are probably not using a thread-safe library.

    Regards,

    Paul McKenzie

  7. #7
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    I find you get abnormal program termination when you throw an exception from a destructor.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured