Commit 283b3dc
committed
Fix invalid MXCSR restore on Linux i386 after SIGFPE
Floating-point exception handling calls restoreControlRegs() from the
SIGFPE handler before throwing a C++ MathExc. On Linux i386, when the
kernel _fpstate magic field was non-zero, the code passed 0 to
LDMXCSR. An all-zero MXCSR is not a valid control register value on
x86 and leaves SSE in a corrupt state, which showed up as crashes
inside libstdc++ (for example std::ostream::sentry) on i686 CI runs.
Read MXCSR from the live CPU when the saved frame does not use the
expected layout (magic != 0), and never load zero: substitute the
usual hardware default 0x1f80 before setMxcsr applies the
clearExceptions mask.
Made-with: Cursor
Signed-off-by: Cary Phillips <cary@ilm.com>1 parent d68fcb6 commit 283b3dc
1 file changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
256 | 266 | | |
257 | 267 | | |
258 | 268 | | |
| |||
0 commit comments