Click to See Complete Forum and Search --> : Threading problem in release version of the software


franky
May 23rd, 1999, 01:00 PM
My socket software works differently in debug version and release version
i traced down to the problem of multithreading.
In Release mode
if i chosed debug multithreaded DLL (project->setting->C/C++ Tab-> Category:
Code Generation -> user runtime library) , my program worked fine! if i use regular
multithreaded DLL. my socket generates trashcode.
My thread class was derived from CWinThread, the sockets class were dyanimically
allocated in one of the functions in my thread class

i began the thread in one of the view's constructor.
T = (CMyThread*)AfxBeginThread(RUNTIME_CLASS(CMyThread), 0, 0, 0);



What could be wrong?

Franky

http://innocreations.cjb.net

May 24th, 1999, 09:55 AM
Something to consider: in the past I have had a Debug version work fine, but the Release version died a horrible death. It turned out that a memory operation was overflowing by 1 byte under certain circumstances. This didn't phase the Debug version, because the memory allocator puts "guard bytes" on the front and back of each allocated block; the overflow simply clobbered the "guard bytes" with no bad side effects. When compiled in Release mode--and without "guard bytes"--the overflow now clobbered the heap information of the next memory block, which had *real bad* side effects. If something works in Debug mode, but fails in Release mode, I start looking long and hard at my memory allocation and manipuation...

Cheers!
Humble Programmer
,,,^..^,,,