Not a "real" problem on a running system, but back in my first year of undergrad I had a computer science assignment that kept faulting with an "Illegal instruction" error on our Solaris systems.
I had a C compiler on my personal computer and the same program ran and compiled fine there, but we had to submit our solution in source code form on the Department's shared system to plug into the class' automated build and test scripts.
Eventually, I discovered that adding an extra space to a comment fixed the error. I wasn't experienced enough to at the time to know how to use GDB to disassemble and debug binaries, but, looking back, I think I must have triggered a compiler bug that misaligned an instruction (Sparcs were 4-byte aligned, IIRC) and adding the extra space somehow fixed the alignment of the generated code.
Sadly I don't think that's true. A first year CS undergraduate would not be writing code that triggered a compiler bug, the real problem was most likely your code.
I suspect you had an error in your program, an off-by-one or other type of overflow, that caused the stack to be executed. Compiling without debug would mean that the code executed was harmless, compiling with debugging symbols (the -g option in gcc) enabled caused a different memory layout, which triggered an attempt to execute data that contained an illegal instruction. Since in debug mode comments are included in the data segment, adding a space to a comment further changed the memory layout making the error innocuous again.
// EDIT After thinking about this a bit more, I'm not entirely convinced by my explanation since comments aren't included in the debug symbols. However, I still think it's more likely that a debug (versus optimized) build had different memory layout, and therefore different behaviour in the presence of a stack/heap smashing bug...?
I had a C compiler on my personal computer and the same program ran and compiled fine there, but we had to submit our solution in source code form on the Department's shared system to plug into the class' automated build and test scripts.
Eventually, I discovered that adding an extra space to a comment fixed the error. I wasn't experienced enough to at the time to know how to use GDB to disassemble and debug binaries, but, looking back, I think I must have triggered a compiler bug that misaligned an instruction (Sparcs were 4-byte aligned, IIRC) and adding the extra space somehow fixed the alignment of the generated code.