159 points · by est31 · 7y ago · 37 comments
"Debugging an evil Go runtime bug" - https://news.ycombinator.com/item?id=15845118
https://github.com/golang/go/issues/20427
Of course there are also good reports where the user actually has found a bug in the compiler.
Though of course most are weird corner case or bugs in new features, there are a surprising number that make you think “wow, how could any program be successfully compiled which this bug in the tree?”
It manifested when you had a single static member of a specific generic type in a class. The program crashed complaining about invalid CLR instructions. If you added a second static member of the same type to the class, or changed the type of the generic parameter, it didn't reproduce.
Turns out it was related to how the compiler used AVX intrinsics on CPUs that supported those instructions.
Pretty fun but took some convincing for people to believe it was a compiler bug.
It is tough to not get overconfident in this diagnosis. If your code happens to see hardware problems on a routine basis, and a real bug surfaces, it is very challenging to not dismiss the latter for the former. It likely took impressive work to diagnose this as far as they have.
Because odds of user vs tool error are so great the software is commonly used. Otherwise it wouldn't be so popular.
In most cases the application is not meant to crash with any fault.
I wonder if this is a compiler bug or a new optimization that broke the code.
In this case, it might be necessary to do a volatile read in case that flag has changed, forcing the compiler to reload it.