Bug 21507

Summary: setlocale changed behavior in glibc-2.2
Product: [Retired] Red Hat Linux Reporter: Need Real Name <jgoldberg>
Component: libcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 7.0CC: dr
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-11-30 11:07:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2000-11-30 06:45:24 UTC
I submitted this before to bug-glibc (#77294).  However, it appears to 
have been closed without a thorough reading.

The recommended usage of setlocale in the libc info pages is
    char *tmp = strdup (setlocale (LC_NUMERIC, NULL));
    setlocale (LC_NUMERIC, "C");
    <operation>
    setlocale (LC_NUMERIC, tmp);
    free (tmp);

This interface implies that setlocale copies the string being passed in.  
If it didn't the last setlocale (... tmp) would store a pointer to a freed 
string.  Unfortunately, this appears to have happened.  The next time 
through this type of operation setlocale (.. NULL) returns the freed 
pointer.  When we attempt to assign that later the sanity checks realize 
it is invalid, and silently switches to "C".  The program seems to work, 
but LC_NUMERIC is now wrong.

This needs to be addressed before glibc-2.2 gets too widely used.  I'm 
already receiving bug reports in gnumeric as a result.  If there is 
anything I can do the help please contact me.

Thanks

Comment 1 Jakub Jelinek 2000-11-30 11:07:46 UTC
Working on a fix.

Comment 2 Jakub Jelinek 2000-12-19 09:29:02 UTC
Fixed in glibc-2.2-9.