Skip to content
Tcl Source Code View Ticket
Login

View Ticket

tk make test fails with "unknown floating-point error" errno

Closed / Fixed218390ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:57:00
OriginalBugID: 4942 Bug
Version: 8.3
SubmitDate: '2000-04-07'
LastModified: '2000-04-10'
Severity: SER
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 4980
OS: Linux
OSVersion: Linux 2.2.14, glibc 2.1.3
FixedDate: '2000-10-25'
ClosedDate: '2000-04-10'


Name:

Peter Runestig


Comments:

The inclution of "#include <huge_val.h>" in tclPort.h might not be the

    best way to do it, but I leave it to you tcl wizards to decide where to

    put it.


    This is a strange bug which must origin from glibc or something, since

    systems affected (like mine) is more or less disabled from using tcl/tk;

    most applications fail in one way or another. If more systems where

    affected, there would be more noise about it, and it would be fixed by

    now.


ReproducibleScript:

Build tcl, make test, build tk, make test.


ObservedBehavior:

[luna@r2 unix]$ make test

LD_LIBRARY_PATH=`pwd`:/home/luna/tcl8.3.0/unix:; \

export LD_LIBRARY_PATH; \

LIBPATH=`pwd`:/home/luna/tcl8.3.0/unix:; export LIBPATH; \

SHLIB_PATH=`pwd`:/home/luna/tcl8.3.0/unix:; \

export SHLIB_PATH; \

TCL_LIBRARY=/home/luna/tcl8.3.0/library; export TCL_LIBRARY; \

TK_LIBRARY=/home/luna/tk8.3.0/library; export TK_LIBRARY; \

./tktest ./../tests/all.tcl -geometry +0+0 

Error in startup script: unknown floating-point error, errno = 84

    while executing

"format %g 5e-5"

    (procedure "::tcltest::initConfig" line 158)

    invoked from within

"::tcltest::initConfig"

    (file "/home/luna/tk8.3.0/unix/./../tests/defs.tcl" line 354)

    invoked from within

"source [file join [pwd] [file dirname [info script]] defs.tcl]"

    invoked from within

"if {[lsearch [namespace children] ::tcltest] == -1} {

    source [file join [pwd] [file dirname [info script]] defs.tcl]

}"

    (file "./../tests/all.tcl" line 12)

make: *** [test] Error 1

[luna@r2 unix]$


DesiredBehavior:

This is a follow-up on TR#4118. The problem, errno != 0 when strtod() didn't fail, affect more files. And testing for d == 0 don't cut it (d could correctly be set to 0 from strtod()), testing for string == end is better.


Patch:

diff -ur tcl8.3.0.orig/generic/tclGet.c tcl8.3.0/generic/tclGet.c

--- tcl8.3.0.orig/generic/tclGet.c      Sat Dec  4 07:15:41 1999

+++ tcl8.3.0/generic/tclGet.c   Fri Apr  7 21:44:10 2000

@@ -222,7 +222,7 @@

         }

        return TCL_ERROR;

     }

-    if (errno != 0) {

+    if (errno != 0 && (d == HUGE_VAL || d == -HUGE_VAL || string == end)) {

         if (interp != (Tcl_Interp *) NULL) {

             TclExprFloatError(interp, d); 

         }

diff -ur tcl8.3.0.orig/generic/tclObj.c tcl8.3.0/generic/tclObj.c

--- tcl8.3.0.orig/generic/tclObj.c      Sat Dec  4 07:15:41 1999

+++ tcl8.3.0/generic/tclObj.c   Fri Apr  7 21:46:17 2000

@@ -1395,7 +1395,7 @@

        }

        return TCL_ERROR;

     }

-    if (errno != 0) {

+    if (errno != 0 && (newDouble == HUGE_VAL || newDouble == -HUGE_VAL || string == end)) {

        if (interp != NULL) {

            TclExprFloatError(interp, newDouble);

        }

diff -ur tcl8.3.0.orig/generic/tclParseExpr.c tcl8.3.0/generic/tclParseExpr.c

--- tcl8.3.0.orig/generic/tclParseExpr.c        Sat Dec  4 07:15:42 1999

+++ tcl8.3.0/generic/tclParseExpr.c     Fri Apr  7 21:46:57 2000

@@ -1556,7 +1556,8 @@

            errno = 0;

            doubleValue = strtod(src, &termPtr);

            if (termPtr != src) {

-               if (errno != 0) {

+               if (errno != 0 && (doubleValue == HUGE_VAL || doubleValue == -HUGE_VAL

+                       || src == termPtr)) {

                    if (interp != NULL) {

                        TclExprFloatError(interp, doubleValue);

                    }

diff -ur tcl8.3.0.orig/generic/tclPort.h tcl8.3.0/generic/tclPort.h

--- tcl8.3.0.orig/generic/tclPort.h     Tue May 25 03:00:27 1999

+++ tcl8.3.0/generic/tclPort.h  Fri Apr  7 20:55:12 2000

@@ -28,4 +28,6 @@

 #    endif

 #endif


+#include <huge_val.h>

+

 #endif /* _TCLPORT */


PatchFiles:

generic/tclGet.c

    generic/tclGet.c

    generic/tclParseExpr.c

    generic/tclPort.h




From original poster:

I (who posted this bug report) must make a significant correction: The
glibc version affected is *2.0.7pre6*, not 2.1.3. Running the test
program posted by Ulrich Ring shows:

------------- err84.c ---------------------
#include <stdlib.h>
#include <errno.h>

int main (int argc, char **argv)
{
        char bytes[2] = { 0xc0 };
        wchar_t wc;
        double d;

        /* May happen inside X11 (XOpenIM) */
        mbtowc (&wc, bytes, 1);
        
        /* Happens inside Tcl which checks for errno == 0 */
        errno = 0;
        d = strtod("1.0", 0);
        printf("ERRNO=%d\n", errno);
}
--------------------------------------------

glibc 2.0.7pre6: ERRNO=84

glibc 2.1.3: ERRNO=0

Sorry for the error in the bug report.

Cheers,
Peter 
-- 04/10/2000 hobbs
welch Closed ticket [218390ffff]. [History diff]2000-10-26 08:21:17
dgp Ticket [218390ffff]: 4 changes [History diff]2001-04-05 06:54:26
Log in (anonymous is fine) to add a comment.