Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
.Applications no longer deadlock when invoking `pthread_atfork` or `dclose` from fork handler callbacks
Previously, applications invoked `pthread_atfork` handler callbacks while `glibc` had acquired an internal lock. As a result, registering fork handlers or calling `dclose` from a fork handler could deadlock applications.
A different synchronization mechanism is now used to protect internal data structures while fork handlers are running. As a result, applications no longer deadlock when invoking `pthread_atfork` or `dclose` from fork handler callbacks.
Created attachment 1721818[details]
hang.c
Previous versions of glibc used a different approach, now, if a thread calls
pthread_atfork from an atfork handler, it will dead lock, attempting to get
the lock, hold during run of the handler.
Looks similar, or same root cause, to issue reported at
https://sourceware.org/bugzilla/show_bug.cgi?id=24595
[[2.28 Regression]: Deadlock in atfork handler which calls dlclose]
The sample hang.c, compiled with:
$ gcc -pthread -o hang hang.c
will show the dead lock.
The problem is this:
static void __attribute__((constructor)) init(void)
{
pthread_atfork(NULL, NULL, init);
}
This recursive call into the fork subsystem now deadlocks. An upstream patch has been posted:
https://sourceware.org/bugzilla/show_bug.cgi?id=24595#c1
There were some concerns about this patch. The key point will be not to call any callback functions while implementation locks are held.
With glibc, re-registering fork handlers after fork (in the subprocess) is not necessary because they are automatically inherited. This is likely not POSIX-compliant, but is long-standing glibc behavior, and it cannot be changed. So as a workaround, you can change this:
static void __attribute__((constructor)) init(void)
{
pthread_atfork(NULL, NULL, init);
}
to:
static void handler(void)
{
// Real fork handler here.
}
static void __attribute__((constructor)) init(void)
{
pthread_atfork(NULL, NULL, handler);
}
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory (glibc bug fix and enhancement update), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2022:7684