1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

posix: Add _Fork [BZ #4737]

Austin Group issue 62 [1] dropped the async-signal-safe requirement
for fork and provided a async-signal-safe _Fork replacement that
does not run the atfork handlers.  It will be included in the next
POSIX standard.

It allow to close a long standing issue to make fork AS-safe (BZ#4737).
As indicated on the bug, besides the internal lock for the atfork
handlers itself; there is no guarantee that the handlers itself will
not introduce more AS-safe issues.

The idea is synchronize fork with the required internal locks to allow
children in multithread processes to use mostly of standard function
(even though POSIX states only AS-safe function should be used).  On
signal handles, _Fork should be used intead and only AS-safe functions
should be used.

For testing, the new tst-_Fork only check basic usage.  I also added
a new tst-mallocfork3 which uses the same strategy to check for
deadlock of tst-mallocfork2 but using threads instead of subprocesses
(and it does deadlock if it replaces _Fork with fork).

[1] https://austingroupbugs.net/view.php?id=62
This commit is contained in:
Adhemerval Zanella
2021-01-19 09:26:31 -03:00
parent dd45734e32
commit c32c868ab8
42 changed files with 451 additions and 17 deletions

View File

@ -2357,6 +2357,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
GLIBC_2.34 _Fork F
GLIBC_2.34 ___adjtimex64 F
GLIBC_2.34 __adjtime64 F
GLIBC_2.34 __aio_suspend_time64 F

View File

@ -2355,6 +2355,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
GLIBC_2.34 _Fork F
GLIBC_2.34 ___adjtimex64 F
GLIBC_2.34 __adjtime64 F
GLIBC_2.34 __aio_suspend_time64 F

View File

@ -2363,6 +2363,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
GLIBC_2.34 _Fork F
GLIBC_2.34 ___adjtimex64 F
GLIBC_2.34 __adjtime64 F
GLIBC_2.34 __aio_suspend_time64 F

View File

@ -2357,6 +2357,7 @@ GLIBC_2.33 mknod F
GLIBC_2.33 mknodat F
GLIBC_2.33 stat F
GLIBC_2.33 stat64 F
GLIBC_2.34 _Fork F
GLIBC_2.34 __libc_start_main F
GLIBC_2.34 __mq_open_2 F
GLIBC_2.34 __pthread_cleanup_routine F