thread safety level of fwide
MaShimiao
mashimiao.fnst@cn.fujitsu.com
Wed Nov 19 07:16:00 GMT 2014
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)
More information about the Libc-help
mailing list