public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/5950] New: strtold_l() segfaults on various distribution of linux
@ 2008-03-17 16:33 boringuy at gmail dot com
  2008-03-17 16:38 ` [Bug libc/5950] " rsa at us dot ibm dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: boringuy at gmail dot com @ 2008-03-17 16:33 UTC (permalink / raw)
  To: glibc-bugs

I have tried glibc 2.5, 2.6 and 2.7 (none of them are available to select above
in the bug form). I have tried on Gentoo, Arch and Debian etch. I have tried on
64-bit and 32-bit machines. They all segfaults. Here is the test case:

#define _GNU_SOURCE 1
#include <xlocale.h>
#include <stdlib.h>

int main() {
    __locale_t x = NULL;
    strtold_l("1234.23423", NULL, x); 
    return 0;
}

Compile with this:
gcc -Wall -g -O2 -o test test.c

I have tried gcc3 and gcc4 and had the same result.

-- 
           Summary: strtold_l() segfaults on various distribution of linux
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: boringuy at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=5950

------- 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] 9+ messages in thread

* [Bug libc/5950] strtold_l() segfaults on various distribution of linux
  2008-03-17 16:33 [Bug libc/5950] New: strtold_l() segfaults on various distribution of linux boringuy at gmail dot com
@ 2008-03-17 16:38 ` rsa at us dot ibm dot com
  2008-03-17 16:53 ` jakub at redhat dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: rsa at us dot ibm dot com @ 2008-03-17 16:38 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From rsa at us dot ibm dot com  2008-03-17 16:38 -------
I'll take this one.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|drepper at redhat dot com   |rsa at us dot ibm dot com
             Status|NEW                         |ASSIGNED


http://sourceware.org/bugzilla/show_bug.cgi?id=5950

------- 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] 9+ messages in thread

* [Bug libc/5950] strtold_l() segfaults on various distribution of linux
  2008-03-17 16:33 [Bug libc/5950] New: strtold_l() segfaults on various distribution of linux boringuy at gmail dot com
  2008-03-17 16:38 ` [Bug libc/5950] " rsa at us dot ibm dot com
@ 2008-03-17 16:53 ` jakub at redhat dot com
  2008-03-17 17:01 ` boringuy at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: jakub at redhat dot com @ 2008-03-17 16:53 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2008-03-17 16:52 -------
Why is it surprising?  NULL is definitely not a valid locale_t object,
and calling strtold_l with invalid locale_t object causes undefined behavior.
The upcoming POSIX standard doesn't cover strtold_l, that is just a GNU
extension, but covers e.g. nl_langinfo_l, for which EINVAL when locale_t
object passed to it is invalid is a may fail type of error, so not detecting
and crashing is fine.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID


http://sourceware.org/bugzilla/show_bug.cgi?id=5950

------- 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] 9+ messages in thread

* [Bug libc/5950] strtold_l() segfaults on various distribution of linux
  2008-03-17 16:33 [Bug libc/5950] New: strtold_l() segfaults on various distribution of linux boringuy at gmail dot com
  2008-03-17 16:38 ` [Bug libc/5950] " rsa at us dot ibm dot com
  2008-03-17 16:53 ` jakub at redhat dot com
@ 2008-03-17 17:01 ` boringuy at gmail dot com
  2008-03-17 17:11 ` jakub at redhat dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: boringuy at gmail dot com @ 2008-03-17 17:01 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From boringuy at gmail dot com  2008-03-17 17:00 -------
Is there a document on how to pass in a correct locale then or can you give an
example? I couldn't find any document on this. Some OS X man page said that by
passing NULL, the default locale or the "C" locale will be used. The
gsoap(http://www.cs.fsu.edu/~engelen/soap.html) library does pass NULL in there.
Once you tell me what to pass on the 3rd argument, I will submit a patch to them
and ask them not to pass in NULL then. Thanks.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=5950

------- 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] 9+ messages in thread

* [Bug libc/5950] strtold_l() segfaults on various distribution of linux
  2008-03-17 16:33 [Bug libc/5950] New: strtold_l() segfaults on various distribution of linux boringuy at gmail dot com
                   ` (2 preceding siblings ...)
  2008-03-17 17:01 ` boringuy at gmail dot com
@ 2008-03-17 17:11 ` jakub at redhat dot com
  2008-03-17 17:29 ` rsa at us dot ibm dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: jakub at redhat dot com @ 2008-03-17 17:11 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2008-03-17 17:11 -------
http://people.redhat.com/drepper/tllocale.ps.gz
You can pass NULL as last argument to newlocale, but not to *_l functions.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=5950

------- 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] 9+ messages in thread

* [Bug libc/5950] strtold_l() segfaults on various distribution of linux
  2008-03-17 16:33 [Bug libc/5950] New: strtold_l() segfaults on various distribution of linux boringuy at gmail dot com
                   ` (3 preceding siblings ...)
  2008-03-17 17:11 ` jakub at redhat dot com
@ 2008-03-17 17:29 ` rsa at us dot ibm dot com
  2008-03-17 17:31 ` rsa at us dot ibm dot com
  2008-03-17 17:59 ` rsa at us dot ibm dot com
  6 siblings, 0 replies; 9+ messages in thread
From: rsa at us dot ibm dot com @ 2008-03-17 17:29 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From rsa at us dot ibm dot com  2008-03-17 17:28 -------
 #include <stdlib.h>
 #include <locale.h>

int main() {
    double d;
    locale_t loc_new = newlocale (LC_ALL_MASK, "C", 0);
    d = strtod_l("1234.23423", NULL, loc_new);
    return 0;
}

Compile with: gcc -Wall test.c -o test -D_GNU_SOURCE=1

I asked Andy Fong to open this bugzilla on the #glibc irc channel because the
documentation on how to use the _l form of strtod is lacking (practically
non-existant minus the one blurb in 'info libc').

>From `info libc`:

   The GNU C library also provides `_l' versions of these functions,
   which take an additional argument, the locale to use in conversion.
   *Note Parsing of Integers::.

I expected that newlocale may appear `info libc` but that's not the case either.

I'm going to ask libc-alpha if there's a suggestion for better documentation.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=5950

------- 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] 9+ messages in thread

* [Bug libc/5950] strtold_l() segfaults on various distribution of linux
  2008-03-17 16:33 [Bug libc/5950] New: strtold_l() segfaults on various distribution of linux boringuy at gmail dot com
                   ` (4 preceding siblings ...)
  2008-03-17 17:29 ` rsa at us dot ibm dot com
@ 2008-03-17 17:31 ` rsa at us dot ibm dot com
  2008-03-17 17:59 ` rsa at us dot ibm dot com
  6 siblings, 0 replies; 9+ messages in thread
From: rsa at us dot ibm dot com @ 2008-03-17 17:31 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From rsa at us dot ibm dot com  2008-03-17 17:30 -------
whoops, forgot to say that my previous code snippet demonstrates how to use
strtod_l with a locale.

Jakub any suggestions on how to make the usage of locales easier to understand?

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=5950

------- 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] 9+ messages in thread

* [Bug libc/5950] strtold_l() segfaults on various distribution of linux
  2008-03-17 16:33 [Bug libc/5950] New: strtold_l() segfaults on various distribution of linux boringuy at gmail dot com
                   ` (5 preceding siblings ...)
  2008-03-17 17:31 ` rsa at us dot ibm dot com
@ 2008-03-17 17:59 ` rsa at us dot ibm dot com
  6 siblings, 0 replies; 9+ messages in thread
From: rsa at us dot ibm dot com @ 2008-03-17 17:59 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From rsa at us dot ibm dot com  2008-03-17 17:58 -------
Drepper's locale .ps file is adequate for figuring out how to get the current
locale for use in strtod_l.

Here's a complete example:

#include <stdlib.h>
#include <locale.h>

int main() {
    double d;
    char *locale = setlocale(LC_ALL,"");
    locale_t loc_new = newlocale (LC_ALL_MASK, locale, 0);
    d = strtod_l("1234.23423", NULL, loc_new); 
    freelocale(loc_new);
    return 0;
}   

gcc -Wall test.c -o test -D_GNU_SOURCE=1

Perhaps this documentation can make it's way into `info libc` in some form.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=5950

------- 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] 9+ messages in thread

* [Bug libc/5950] strtold_l() segfaults on various distribution of linux
       [not found] <bug-5950-131@http.sourceware.org/bugzilla/>
@ 2014-07-01 21:21 ` fweimer at redhat dot com
  0 siblings, 0 replies; 9+ messages in thread
From: fweimer at redhat dot com @ 2014-07-01 21:21 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=5950

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-07-01 21:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-17 16:33 [Bug libc/5950] New: strtold_l() segfaults on various distribution of linux boringuy at gmail dot com
2008-03-17 16:38 ` [Bug libc/5950] " rsa at us dot ibm dot com
2008-03-17 16:53 ` jakub at redhat dot com
2008-03-17 17:01 ` boringuy at gmail dot com
2008-03-17 17:11 ` jakub at redhat dot com
2008-03-17 17:29 ` rsa at us dot ibm dot com
2008-03-17 17:31 ` rsa at us dot ibm dot com
2008-03-17 17:59 ` rsa at us dot ibm dot com
     [not found] <bug-5950-131@http.sourceware.org/bugzilla/>
2014-07-01 21:21 ` fweimer at redhat 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).