From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19042 invoked by alias); 1 Oct 2011 17:39:22 -0000 Received: (qmail 19031 invoked by uid 22791); 1 Oct 2011 17:39:21 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 01 Oct 2011 17:38:59 +0000 From: "jim at meyering dot net" To: glibc-bugs@sources.redhat.com Subject: [Bug libc/13246] New: RFE: strtold: do not include uninitialized bytes when converting "NaN" Date: Sat, 01 Oct 2011 17:39:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jim at meyering dot net X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: drepper.fsp at gmail dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00000.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=13246 Bug #: 13246 Summary: RFE: strtold: do not include uninitialized bytes when converting "NaN" Product: glibc Version: 2.14 Status: NEW Severity: normal Priority: P2 Component: libc AssignedTo: drepper.fsp@gmail.com ReportedBy: jim@meyering.net Classification: Unclassified strtold ("nan", NULL) appears to return a result that depends on the prior state of the stack. That non-determinism caused GNU sort to infloop, but we've worked around this glibc-specific issue: http://debbugs.gnu.org/9612 Here's a little program to demonstrate the problem. Note how the results differ with compilation options: #include #include static char * fmt_nan (long double x) { unsigned int i; static char buf[33]; unsigned char const *p = (unsigned char const *) &x; for (i = 0; i < sizeof x; i++) sprintf (buf + 2*i, "%02x", *p++); return buf; } int main () { const char *q = "nan"; long double x = strtold (q, NULL); printf ("%s\n", fmt_nan (x)); x = 0; x = strtold (q, NULL); printf ("%s\n", fmt_nan (x)); return 0; } $ gcc -O0 -Wall -Wextra -W /t/strtold-bogosity.c && ./a.out 00000000000000c0ff7f400000000000 00000000000000c0ff7f000000000000 $ gcc -O1 -Wall -Wextra -W /t/strtold-bogosity.c && ./a.out 00000000000000c0ff7f000000000000 00000000000000c0ff7f000000000000 -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.