public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/6712] New: Race condition in calling setlocale()
@ 2008-07-01 10:59 sharyathi at in dot ibm dot com
2008-07-01 11:11 ` [Bug libc/6712] " sharyathi at in dot ibm dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: sharyathi at in dot ibm dot com @ 2008-07-01 10:59 UTC (permalink / raw)
To: glibc-bugs
Description
During PHP engine development it was observed that a thread calling
strcmp() would crash if another thread was also calling setlocale().
The problem is difficult to reproduce, but the following is a
line-by-line analysis of where the race condition exists.
-----------------------------------------------------------------------
char *
setlocale (int category, const char *locale)
{
char *locale_path;
.......
/* Does user want name of current locale? */
if (locale == NULL)
return (char *) _nl_global_locale.__names[category];
if (strcmp (locale, _nl_global_locale.__names[category]) == 0)
<== SIGSEGVs while accessing _nl_global_locale
..........
if (category == LC_ALL)
{
..........
/* Protect global data. */
__libc_rwlock_wrlock (__libc_setlocale_lock);
..........
setname (LC_ALL, composite)
<== Frees the global variable _nl_global_locale.__names[category]
..........
/* Critical section left. */
__libc_rwlock_unlock (__libc_setlocale_lock);
} //category == LC_ALL
..........
} //setlocale end of function
-----------------------------------------------------------------------
Though setlocale() is not on the POSIX.1 list of async-signal safe
functions as in section 2.4.3
http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04
It still needs to be thread safe according to section 2.9.1 in
http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html
--
Summary: Race condition in calling setlocale()
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: sharyathi at in dot ibm dot com
CC: bmark at us dot ibm dot com,glibc-bugs at sources dot
redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=6712
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libc/6712] Race condition in calling setlocale()
2008-07-01 10:59 [Bug libc/6712] New: Race condition in calling setlocale() sharyathi at in dot ibm dot com
@ 2008-07-01 11:11 ` sharyathi at in dot ibm dot com
2008-07-01 11:14 ` sharyathi at in dot ibm dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: sharyathi at in dot ibm dot com @ 2008-07-01 11:11 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From sharyathi at in dot ibm dot com 2008-07-01 11:11 -------
Created an attachment (id=2810)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=2810&action=view)
Change log for the patch
This is the change log for the proposed patch
--
http://sourceware.org/bugzilla/show_bug.cgi?id=6712
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libc/6712] Race condition in calling setlocale()
2008-07-01 10:59 [Bug libc/6712] New: Race condition in calling setlocale() sharyathi at in dot ibm dot com
2008-07-01 11:11 ` [Bug libc/6712] " sharyathi at in dot ibm dot com
@ 2008-07-01 11:14 ` sharyathi at in dot ibm dot com
2008-07-20 17:30 ` drepper at redhat dot com
2008-07-23 8:38 ` sharyathi at in dot ibm dot com
3 siblings, 0 replies; 5+ messages in thread
From: sharyathi at in dot ibm dot com @ 2008-07-01 11:14 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From sharyathi at in dot ibm dot com 2008-07-01 11:13 -------
Created an attachment (id=2811)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=2811&action=view)
Patch to fix the setlocale race issue
This is the proposed fix to the problem
Testing of the patch
There was no regression observed while testing. Testing was done on
x86_64-linux-gnu box where the application was built as 32 bit.
Thanks
Sharyathi
--
http://sourceware.org/bugzilla/show_bug.cgi?id=6712
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libc/6712] Race condition in calling setlocale()
2008-07-01 10:59 [Bug libc/6712] New: Race condition in calling setlocale() sharyathi at in dot ibm dot com
2008-07-01 11:11 ` [Bug libc/6712] " sharyathi at in dot ibm dot com
2008-07-01 11:14 ` sharyathi at in dot ibm dot com
@ 2008-07-20 17:30 ` drepper at redhat dot com
2008-07-23 8:38 ` sharyathi at in dot ibm dot com
3 siblings, 0 replies; 5+ messages in thread
From: drepper at redhat dot com @ 2008-07-20 17:30 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2008-07-20 17:29 -------
I checked in a different patch.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://sourceware.org/bugzilla/show_bug.cgi?id=6712
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libc/6712] Race condition in calling setlocale()
2008-07-01 10:59 [Bug libc/6712] New: Race condition in calling setlocale() sharyathi at in dot ibm dot com
` (2 preceding siblings ...)
2008-07-20 17:30 ` drepper at redhat dot com
@ 2008-07-23 8:38 ` sharyathi at in dot ibm dot com
3 siblings, 0 replies; 5+ messages in thread
From: sharyathi at in dot ibm dot com @ 2008-07-23 8:38 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From sharyathi at in dot ibm dot com 2008-07-23 08:38 -------
Ulrich
Can you point to the patch added to glibc
Thanks
Sharyathi
--
http://sourceware.org/bugzilla/show_bug.cgi?id=6712
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-07-23 8:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-01 10:59 [Bug libc/6712] New: Race condition in calling setlocale() sharyathi at in dot ibm dot com
2008-07-01 11:11 ` [Bug libc/6712] " sharyathi at in dot ibm dot com
2008-07-01 11:14 ` sharyathi at in dot ibm dot com
2008-07-20 17:30 ` drepper at redhat dot com
2008-07-23 8:38 ` sharyathi at in dot ibm dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).