gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

OffTopic > need better DEBUGGING solution - multithreaded / winXP

#154220 - silent_code - Sat Apr 12, 2008 11:25 pm

hi!

recently, after upgrading my (realtime) lightmapper to multithreading (dual core wooh!), i started getting a silly bug, that simply won't go away no matter what i do.
it issues an access violation in seemingly random situations - most of the time, if not always, when deleting stuff. i have already redone some algorithms and it's pretty much stable most of the time. still, it will crash on some occasions. it will do any n > 0 lightmapping iterations flawlessly, but on any unspecific m-th iteration it will, with no obvious reason, *rape* the system and terminate with the infamous return status -1073741819 (access violation). after taking my memory debugger out (which uses stl::list - not thread save, is it?) errors will still occur, but less often. although, *all* relevant sections (accessing any non local variable, engine subsystem etc.) are already synchronized with a mutex...
now, the thing is, that it will not crash while debugging!

also, it'll crash while terminating - the last line of the core's log won't be written when it's shutting down - it's just versioning info, time and date etc., but again, NOT always. ????
that's by the way not a MT problem. again, no crashes while debugging!

multithreading is done via _beginthread(procedure , 0, threaddata). synchronisation is done with WaitForSingleObject(mutex, INFINITE) and ReleaseMutex(mutex).
i have thought about using posix threads, but i kind of like this minimal interface, as i really don't need anything more.

i'm still working on how to isolate and replicate the problem, but it simply happens soooo randomly, that i'm having big problems doing that.

well, i don't want to bore you any more with the bloody details. btw: i'm using code::blocks ide and gdb 5.2.1 as a debugger (for [mingw] gcc 3.5 all latest stable builds, iirc).

i simply call _beginthread() with all needed arguments and i didn't set any gcc flags etc. i also did not link against any special libraries. msdn suggests linking against the MT CRT variant, but i can't find it in gcc's lib folder, so i guess it's not needed (i'm being naive, yeah). any suggestions?
and remember, it works ... but only most of the time. ;^)

what about recommendations? like free debugging software / code, good tutorials / articles on "deep" [possibly multithread] debugging?

thanks in advance!