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.
Bug 1275384 - Segmentation violation can occur within glibc if fork() is used in a multi-threaded application
Summary: Segmentation violation can occur within glibc if fork() is used in a multi-th...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: glibc
Version: 6.7
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Marek Polacek
QA Contact: Arjun Shankar
Lenka Špačková
URL:
Whiteboard:
Depends On:
Blocks: 1322544
TreeView+ depends on / blocked
 
Reported: 2015-10-26 17:57 UTC by Chris Dickens
Modified: 2016-10-11 19:26 UTC (History)
8 users (show)

Fixed In Version: glibc-2.12-1.188.el6_8
Doc Type: Bug Fix
Doc Text:
Multithreaded applications no longer crash when calling dprintf() and fork() concurrently Multithreaded applications that use the dprintf() and fork() *glibc* functions concurrently could previously terminate unexpectedly with a segmentation fault. With this update, the fork() implementation has been fixed to ignore temporary streams created by dprintf(), and the described problem no longer occurs.
Clone Of:
: 1322544 (view as bug list)
Environment:
Last Closed: 2016-05-10 21:28:13 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Sample application that elicits the described behavior (3.26 KB, text/plain)
2015-10-26 17:59 UTC, Chris Dickens
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1323134 0 low CLOSED glibc: stdio race condition causes crash during process shutdown 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2016:0834 0 normal SHIPPED_LIVE glibc bug fix update 2016-05-10 22:41:39 UTC
Sourceware 12847 0 None None None 2019-04-08 17:03:04 UTC

Internal Links: 1323134

Description Chris Dickens 2015-10-26 17:57:22 UTC
User-Agent:       Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
Build Identifier: 

A segmentation violation can occur within glibc in the child process after fork() in a multi-threaded application if other threads in the application are calling (v)dprintf or syslog() (a glibc function that calls dprintf() internally) at the same time as the fork.

The root cause is a NULL pointer dereference inside the fresetlockfiles() function for the IO's _lock member. The (v)dprintf functions add an IO file to the list with a NULL lock, and the lock pointer or IO flags are not checked prior to the dereference.

Reference: https://sourceware.org/bugzilla/show_bug.cgi?id=12847

Reproducible: Always

Steps to Reproduce:
Run a multi-threaded application that uses both fork() and dprintf()/vdprintf()/syslog()
Actual Results:  
The child process will intermittently experience a segmentation violation immediately after fork(), before the call to fork() ever returns within the child.

Expected Results:  
The child process should not experience any segmentation violation before fork() returns.

Comment 1 Chris Dickens 2015-10-26 17:59:27 UTC
Created attachment 1086567 [details]
Sample application that elicits the described behavior

Comment 4 Carlos O'Donell 2015-10-26 19:36:13 UTC
(In reply to Chris Dickens from comment #0)
> The root cause is a NULL pointer dereference inside the fresetlockfiles()
> function for the IO's _lock member. The (v)dprintf functions add an IO file
> to the list with a NULL lock, and the lock pointer or IO flags are not
> checked prior to the dereference.

Do you have a specific application that is failing?

Comment 5 Chris Dickens 2015-10-27 14:14:35 UTC
(In reply to Carlos O'Donell from comment #4)
> (In reply to Chris Dickens from comment #0)
> > The root cause is a NULL pointer dereference inside the fresetlockfiles()
> > function for the IO's _lock member. The (v)dprintf functions add an IO file
> > to the list with a NULL lock, and the lock pointer or IO flags are not
> > checked prior to the dereference.
> 
> Do you have a specific application that is failing?

It is an in-house application, nothing commercial or open source. The coredump led me to discovering it was occurring within glibc before fork() ever returned in the child process.

Comment 14 Carlos O'Donell 2016-04-01 14:07:22 UTC
Chris,

This issue is planned to be fixed in RHEL 6.8.

I wanted to inform you that there is another dprintf issue that was not fixed. During process shutdown, after exit() has been called, if there are threads still carrying out IO via dprintf() you will also get a segfault.

We have filed bug 1323134 for the dprintf/exit failure case. Could you please comment in that bug if the dprintf/exit failure is also relevant to your use case? The fork failure is fixed and that is, in my opinion, that most important failure. In the case of exit you are shutting down the process and so should more than likely be stopping all threads (or you'll get half-written IO as the process is torn down).

Thanks.

Comment 18 errata-xmlrpc 2016-05-10 21:28:13 UTC
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, 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://rhn.redhat.com/errata/RHBA-2016-0834.html


Note You need to log in before you can comment on or make changes to this bug.