2 ms·
Those instructions generate an interrupt; you'd have to define the OS ABI to make those instructions trap back to the application in a catchable way.
by JoshTriplett 12y ago
Those instructions generate an interrupt; you'd have to define the OS ABI to make those instructions trap back to the application in a catchable way.
- ahomescu1 12y agoIf you put the INTO immediately after the overflowing instruction, the OS could just go back one instruction (harder than it seems, but not impossible). Wouldn't that work?
- JoshTriplett 12y agoThat'd require the OS to define that as part of the ABI. Also, you almost certainly don't want to just go back an instruction; you want to catch and handle the overflow.
- userbinator 12y agoThere's an existing way to do this already: SIGFPE + the UNIX signal-handling mechanism. Integer overflow is even mentioned as one of the possible causes of this signal. The BSDs have a defined constant FPE_INTOVF_TRAP for it too. On Windows, SEH is an equivalent functionality.