[uClibc 0001382]: strtod() ERANGE not set on underflow

bugs at busybox.net bugs at busybox.net
Tue Jun 12 13:51:29 UTC 2007


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=1382 
====================================================================== 
Reported By:                chmeee
Assigned To:                uClibc
====================================================================== 
Project:                    uClibc
Issue ID:                   1382
Category:                   Math Library
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             06-06-2007 10:42 PDT
Last Modified:              06-12-2007 06:51 PDT
====================================================================== 
Summary:                    strtod() ERANGE not set on underflow
Description: 
The Xerces test suite checks for underflow on strtod() parsing of the
string

+2.250738585072014e-329

Also with the negative value of this.  It correctly returns 0, but does
not set errno to ERANGE.
====================================================================== 

---------------------------------------------------------------------- 
 bernhardf - 06-06-07 11:35  
---------------------------------------------------------------------- 
May i suggest that you look into libc/stdlib/_strtod.c, looks like
__fp_range_check() to verify that ERANGE is also set on underflow and
submit a patch?

thanks,

 

---------------------------------------------------------------------- 
 chmeee - 06-07-07 11:33  
---------------------------------------------------------------------- 
I'm looking into it, and did read through that function before submitting
the bug report, but I'm not quite sure how to fix it without breaking
strtold.  I've looked through glibc's strtod(), and that detects overflow
and underflow during the parse, not afterwards, and it's the same with
strtold() and strtof().  I was hoping someone with better floating point
skills would be able to more easily address it. 

---------------------------------------------------------------------- 
 chmeee - 06-12-07 06:51  
---------------------------------------------------------------------- 
This fix seems to work, but someone with real floating point experience
should verify:

Index: libc/stdlib/strtod.c
===================================================================
--- libc/stdlib/strtod.c        (revision 2124)
+++ libc/stdlib/strtod.c        (working copy)
@@ -506,7 +506,7 @@ __fpmax_t __XL_NPP(__strtofpmax)(const W
 extern void __fp_range_check(__fpmax_t y, __fpmax_t x)
 {
        if (__FPMAX_ZERO_OR_INF_CHECK(y) /* y is 0 or +/- infinity */
-               && (y != 0)     /* y is not 0 (could have x>0, y==0 if
underflow) */
+       //      && (y != 0)     /* y is not 0 (could have x>0, y==0 if
underflow) */
                && !__FPMAX_ZERO_OR_INF_CHECK(x) /* x is not 0 or +/-
infinity */
                ) {
                __set_errno(ERANGE);    /* Then x is not in y's range. */ 

---------------------------------------------------------------------- 
 chmeee - 06-12-07 06:51  
---------------------------------------------------------------------- 
This fix seems to work, but someone with real floating point experience
should verify:

Index: libc/stdlib/strtod.c
===================================================================
--- libc/stdlib/strtod.c        (revision XXXX)
+++ libc/stdlib/strtod.c        (working copy)
@@ -506,7 +506,7 @@ __fpmax_t __XL_NPP(__strtofpmax)(const W
 extern void __fp_range_check(__fpmax_t y, __fpmax_t x)
 {
        if (__FPMAX_ZERO_OR_INF_CHECK(y) /* y is 0 or +/- infinity */
-               && (y != 0)     /* y is not 0 (could have x>0, y==0 if
underflow) */
+       //      && (y != 0)     /* y is not 0 (could have x>0, y==0 if
underflow) */
                && !__FPMAX_ZERO_OR_INF_CHECK(x) /* x is not 0 or +/-
infinity */
                ) {
                __set_errno(ERANGE);    /* Then x is not in y's range. */ 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
06-06-07 10:42  chmeee         New Issue                                    
06-06-07 10:42  chmeee         Status                   new => assigned     
06-06-07 10:42  chmeee         Assigned To               => uClibc          
06-06-07 11:34  bernhardf      Note Added: 0002459                          
06-06-07 11:35  bernhardf      Note Edited: 0002459                         
06-07-07 11:33  chmeee         Note Added: 0002461                          
06-12-07 06:51  chmeee         Note Added: 0002476                          
06-12-07 06:51  chmeee         Note Added: 0002477                          
======================================================================




More information about the uClibc-cvs mailing list