Re:Why isn't memset() async-signal-safe?
by kazinator on Wednesday January 04, 2017 @06:35AM
(#13317371)
OK there we go, then. A compiler that conforms to the ABI generates code which clears the flag, if necessary. Interrupts preserve the flag. Thus, the flag should not be surprisingly set on entry into memcpy. If so, there is a bug.
Re:Why isn't memset() async-signal-safe?
by olegolegovich on Wednesday January 04, 2017 @08:03AM
(#13317891)
> A compiler that conforms to the ABI generates code which clears the flag, if necessary.
I'm sorry, I do not follow. The conforming compiler expects that the functions are called with the clear flag. The non-conforming kernel on the other hand does not clear the flag before calling the signal handler which breaks it.
It can not have arbitrary value on entry. x86-64 ABI mandates that the flag is cleared before any function is called (3.2.1 Registers and the Stack Frame: "The direction flag in the %eflags register must be clear on function entry, and on function return.")