[PATCH] Make abort() AS-safe (Bug 26275).

Rich Felker dalias@libc.org
Tue Sep 29 14:42:07 GMT 2020


On Tue, Sep 29, 2020 at 08:54:59AM +0200, Florian Weimer wrote:
> * Rich Felker:
> 
> > Is there a reason to take the lock across fork rather than just
> > resetting it in the child? After seeing this I'm working on fixing the
> > same issue in musl and was about to take the lock, but realized ours
> > isn't actually protecting any userspace data state, just excluding
> > sigaction on SIGABRT during abort.
> 
> It's also necessary to stop the fork because the subprocess could
> otherwise observe the impossible SIG_DFL state.  In case the signal
> handler returns, the implementation needs to produce a termination
> status with SIGABRT as the termination signal, and the only way I can
> see to achieve that is to remove the signal handler and send the
> signal again.  This suggests that a lock in sigaction is needed as
> well.

Yes, in musl we already have the lock in sigaction -- that's the whole
point of the lock. To prevent other threads from fighting to change
the disposition back to SIG_IGN or a signal handler while abort is
trying to change it to SIG_DFL.

> But for the fork case, restting the lock in the new subprocess should
> be sufficient.

I don't follow. Do you mean taking the lock in the parent, but just
resetting it in the child? That should work but I don't see how it has
any advantage over just releasing it in the child.

Rich


More information about the Libc-alpha mailing list