-
- Downloads
signal handling: fix FPU clobbering bug
This patch adds missing FPU-state saving when calling signal handlers. The state is saved on the stack, to allow nesting of signal handling (delivery of a second signal while a first signal's handler is running). In Linux calling conventions, the FPU state is caller-saved, i.e., a called function can use FPU at will because the caller is assumed to have saved it if needed. However, signal handlers are called asynchronously, possibly in the middle of some FPU computation without that computation getting a chance to save its state. So we must save this state before calling the signal handling function. Without this fix, we had problems even if the signal handlers themselves did not use the FPU. A typical scenario - which we encountered in the "sunflow" benchmark - is that the signal handler does something which uses a mutex (e.g., malloc()) and causes a reschedule. The reschedule, not a preempt(), thinks it does not need to save the FPU state, and the thread we switch to clobbers this state.
Loading
Please register or sign in to comment