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
Re: Debugging a multithreaded DLL with STL
Quote:
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