▲ | Sharlin 4 days ago | ||||||||||||||||||||||||||||||||||||||||
Signed overflow is undefined behavior in C, so pretty much anything could happen. Though this crash seems to be deterministic between platforms and compilers, so probably not about that. TFA says the variable is being compared to its previous value, and that comparison presumably assumes new < old cannot happen. And when it does, it could easily lead to eg. stack corruption. C after all happily goes to UB land if, for example, some execution path doesn’t return a value in a function that’s supposed to return a value. | |||||||||||||||||||||||||||||||||||||||||
▲ | account42 4 days ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||
Just because the language standard allows for anything to happen doesn't mean that actually anything can happen with real compilers. It's still a good question to think about how it could actually lead to a crash. | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
▲ | phkahler 4 days ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||
That doesn't make sense. If new < old cant happen there is no need to make a comparison. Stack corruption? Nah, its a counter not an index or pointer or it would fail sooner. But then what is the failure? IDK | |||||||||||||||||||||||||||||||||||||||||
|