Bug 26275 - abort(3) is not signal-safe
Summary: abort(3) is not signal-safe
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-22 04:31 UTC by hyd-dev
Modified: 2020-09-27 16:38 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 hyd-dev 2020-08-11 17:30:36 UTC
In addition to POSIX (https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03_03), it's also required to be signal-safe by ISO C and ISO C++ 17 (https://github.com/cplusplus/draft/blob/n4659/source/support.tex#L1643-L1644).
Comment 2 Carlos O'Donell 2020-08-12 00:26:30 UTC
The manual is wrong and needs fixing.

Since glibc 2.27 we've been AS-safe in that we no longer flush.
Comment 3 hyd-dev 2020-08-12 07:24:40 UTC
But what about the lock: https://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/abort.c;h=df98782dd7ea6c1476184a365bd9f3954f481a18;hb=refs/heads/master#l54?
Holding that lock is not signal-safe, even it is recursive. For example, a thread is calls abort(3) and acquires the lock. Then another thread fork(2), and the child process calls abort(3) and tries to lock the lock, leading to deadlock.
Comment 4 Carlos O'Donell 2020-09-24 21:46:54 UTC
(In reply to hyd-dev from comment #3)
> But what about the lock:
> https://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/abort.c;
> h=df98782dd7ea6c1476184a365bd9f3954f481a18;hb=refs/heads/master#l54?
> Holding that lock is not signal-safe, even it is recursive. For example, a
> thread is calls abort(3) and acquires the lock. Then another thread fork(2),
> and the child process calls abort(3) and tries to lock the lock, leading to
> deadlock.

You are correct. I missed the local lock to make abort MT-safe. In this case we to extend the lock to coordinate with fork like we do with malloc and the stdio locks. Let me test a quick fix.
Comment 5 Carlos O'Donell 2020-09-27 14:21:34 UTC
Posted for review:
https://sourceware.org/pipermail/libc-alpha/2020-September/117934.html