23

I've been writing a complex mutation engine that dynamically modifies compiled C++ code. Now there's alot of assembly involved, but I got it to work. I finished off writing the last unit test before it was time to port it all to windows. I switched into a release build, ready to bask in the glory of it all. FUCKING GCC OPTIMIZATIONS BROKE EVERYTHING. I had been doing all my dev in debug mode and now some obscure optimization GCC does in release mode is causing a segfault...somewhere. Just when I thought I was done 😅

Comments
  • 4
    Stupid proposal of the day:
    Deliver without GCC optimization, or try with the lesser Level (O1)?
    If i were you, GCC -O0 and "fuck yourself stupid compiler" -cit.
  • 0
    Sounds like a case of undefined behaviour! Compilers love to mess you up when you have undefined behaviour! Static analysers are good at warning about those, and then there's dynamic analysers for catching the bug.
  • 7
    I found it! With optimizations on GCC uses the eflags in certain cases to avoid doing extra condition branches. My assembly incorrectly cleared the zero flag in a place where it shouldn't have, causing it to go down the wrong branch, causing all sorts of bad things. All fixed 😁

    Specifically GCC turned what was a simple condition jump into a test + cmovle instruction pair. Making the issue non obvious because execution of cmovle is based upon the state of the eflags
  • 5
    This rant made me way too happy. It's refreshing to find someone else on here who works with assembly, instead of yet another web dev.
  • 0
    I miss assembly so much. 🙁
Add Comment