Hacker News new | ask | show | jobs
by overfl0w 526 days ago
The bug in question was a out of bounds writing to a stack allocated buffer. The compiler would choose to store some variables to registers for optimization purposes. When calling a function - these registers' contents would get pushed to the stack. The faulty called function would modify those same register contents on the stack. When returning to the parent function and restoring the context - the registers would have faulty values.

When adding a print or a check - the compiler would choose different variables to store in the registers. They would still get overwritten by the faulty function but the bug would not be observed.

I agree that it's almost never the compiler's fault though - but sometimes its optimization choices make it harder to reproduce a bug.

Edit: The faulty function was a somewhat standard function, part of the SDK. This taught me that the standard functions are almost never faulty. Until they are :-)

1 comments

Sounds like a fun one. I know Im a broken man because I actually-like- tracking down those kinds of bugs lol.