This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 46446 - fflush(0) not thread safe
fflush(0) not thread safe
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.1
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Aaron Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-06-28 14:09 EDT by André Johansen
Modified: 2016-11-24 10:08 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-11-23 15:42:21 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Threaded fflush(0) example code (1.96 KB, text/plain)
2001-06-28 14:14 EDT, André Johansen
no flags Details

  None (edit)
Description André Johansen 2001-06-28 14:09:34 EDT
Calling fflush(0) in a multi-threaded application can crash it.
I will attach a program that can reproduce this problem; I've tried it
on both Red Hat Linux v6.2 and v7.1, both fully updated,
both dual Pentium 3 machines.

By inspecting the GNU libc code, it seems no locking is done in the
_IO_flush_all() call, so I guess closing a file during fflush(0) can
break the list-iteration done in that function.

The attached example crashes much faster on the v7.1 machine (which is
also faster); the v7.1 is updated vanilla, the v6.2 one uses GCC v2.95.3
as compiler.  On the v7.1 machine, it crashes in a few seconds, on the 6.2
machine, it can take a few minutes before it crashes.

All crashes are SIGSEGV.

I know ISO C does not say anything about thread safety in the IO
library, but GNU libio/libc seems to be implemented with thread safety
in mind.
Comment 1 André Johansen 2001-06-28 14:14:33 EDT
Created attachment 22086 [details]
Threaded fflush(0) example code
Comment 2 Jakub Jelinek 2001-07-25 08:37:55 EDT
Should be fixed in glibc-2.2.3-17.
At least I run the test for more than an hour without any problems.
Comment 3 André Johansen 2003-11-23 15:40:46 EST
Jakub, I think this bug can be closed -- it has worked correctly for 
ages now ;-) 
 

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