Handmade Hero»Forums»Code
The_8th_mage
69 posts / 1 project
how to bring forth synchronization bugs
Hi,
I have some synchronization bugs in my debugger, and the only way to bring it forth right now is making something run and waiting for 5 minutes until it hits. clearly, that's not a great thing to trying to debug, is there any way to make those bugs easier to hit? I'm looking for something like finding buffer overflows and underflows with allocations of things on boundries of pages, if you know the trick.
Thanks
The_8th_mage
Mārtiņš Možeiko
2559 posts / 2 projects
how to bring forth synchronization bugs
There's no easy way.
On Linux there are *very* good tools that helps with debugging multi-threading issues: valgrind's Helgrind and DRD, gcc/clang's ThreadSanitizer. Not sure if there is anything good on Windows. There are some commercial tools like Intel Inspector, but I haven't used them so no idea how good they are.

I suggest to design your architecture for communications in a way which makes hard to make mistakes with multi-threaded synchronization. Don't put multi-threaded primitives (events, critical sections, etc) all over code. Use them only in very few places that are responsible for receiving/sending information to different thread and can be easily debugged. So rest of code for thread can be synchronization-free.

As for finding buffer over/under-flows with page boundary allocations - try using address address sanitizer (Dr.Memory on Windows). It is so much better than those allocation tricks.