Bug 463301 - Race condition in the glibc function vfprintf()
Summary: Race condition in the glibc function vfprintf()
Status: NEW
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Current
Hardware: x86-64 openSUSE 11.1
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Andreas Schwab
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-02 17:47 UTC by Bart Van Assche
Modified: 2020-02-26 11:40 UTC (History)
1 user (show)

See Also:
Found By: Community User
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bart Van Assche 2009-01-02 17:47:05 UTC
Apparently calling printf() from more than one thread triggers a race condition on _IO_2_1_stdout_.file._mode. This race is triggered by line 1270 of file vfprintf.c, which contains the following statement: "ORIENT;". This statement tests some bits in _IO_2_1_stdout_.file._mode and takes a decision. Later on vfprintf() calls _IO_flockfile(). This is a race condition because other threads may change these bits after vfprintf() tested these bits and before vfprintf() calls _IO_flockfile().

I discovered this issue through verifying a multithreaded program with DRD (a data race detection tool). The first error message printed by DRD for a program that calls printf() from more than one thread is as follows:

$ svn info .
URL: svn://svn.valgrind.org/valgrind/branches/DRDDEV
...
Revision: 8895
...
$ ./vg-in-place --var-info=yes --tool=drd drd/tests/circular_buffer
...
==9097== Thread 3:
==9097== Conflicting load by thread 3/3 at 0x0539d840 size 4
==9097==    at 0x508D460: vfprintf (vfprintf.c:1270)
==9097==    by 0x5097599: printf (printf.c:35)
==9097==    by 0x400D99: buffer_send (circular_buffer.c:105)
==9097==    by 0x400E08: producer (circular_buffer.c:124)
==9097==    by 0x4C2A047: vg_thread_wrapper (drd_pthread_intercepts.c:184)
==9097==    by 0x4E3506F: start_thread (pthread_create.c:297)
==9097==    by 0x511D0EC: clone (clone.S:112)
==9097== Location 0x539d840 is 0 bytes inside _IO_2_1_stdout_.file._mode,
==9097== a global variable declared at stdfiles.c:70
...
Comment 1 Simon Lees 2017-08-11 04:39:09 UTC
Re assigning to current maintainer to check if it still exists