Bug 46446 - fflush(0) not thread safe
Summary: fflush(0) not thread safe
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc   
(Show other bugs)
Version: 7.1
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Aaron Brown
Depends On:
TreeView+ depends on / blocked
Reported: 2001-06-28 18:09 UTC by André Johansen
Modified: 2016-11-24 15:08 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-11-23 20:42:21 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
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 18:14 UTC, André Johansen
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2001:121 normal SHIPPED_LIVE GNU C Library bugfix update 2001-10-04 04:00:00 UTC

Description André Johansen 2001-06-28 18:09:34 UTC
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 18:14:33 UTC
Created attachment 22086 [details]
Threaded fflush(0) example code

Comment 2 Jakub Jelinek 2001-07-25 12:37:55 UTC
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 20:40:46 UTC
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.