Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The struggle is real! Compiling with debug enabled does change timing enough to hide (or surface!) race conditions.

The best way I've found to deal with this is:

1. Compile with -O2 (or for firmware, -Os) by default, and generate debug symbols in the elf file. Crank it up to -O3 only on a file-by-file basis with #pragma

2. Collect the process memory when an issue is hit

3. Debug it asynchronously using the debug symbols + the memory.

That way, the debugging & the running are decoupled and the timing is stable.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: