This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
thread safety level of fwide
- From: MaShimiao <mashimiao dot fnst at cn dot fujitsu dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>, "Carlos O'Donell" <carlos at redhat dot com>
- Cc: <libc-help at sourceware dot org>
- Date: Wed, 19 Nov 2014 15:15:20 +0800
- Subject: thread safety level of fwide
- Authentication-results: sourceware.org; auth=none
Hi, everyone
fwide() is annotated as
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock
in the glibc manual.
After reading it's source code, I think it should be marked with race:stream.
The reasoning is fwide() uses fp several times inside without holding the lock over all of them.
How do you think about that?
The fwide()'s code is as follows:
int
fwide (fp, mode)
_IO_FILE *fp;
int mode;
{
int result;
/* Normalize the value. */
mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1);
if (mode == 0 || fp->_mode != 0)
/* The caller simply wants to know about the current orientation
or the orientation already has been determined. */
return fp->_mode;
_IO_acquire_lock (fp);
result = _IO_fwide (fp, mode);
_IO_release_lock (fp);
return result;
}
Best regards
--
Ma Shimiao
Development Dept.I
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)