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.
Created attachment 1086567 [details] Sample application that elicits the described behavior
(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?
(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.
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.
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