Skip to content
Tcl Source Code History Of Ticket e3dcab1d14c0bcc5
Login

History Of Ticket e3dcab1d14c0bcc5

Artifacts Associated With Ticket e3dcab1d14c0bcc5

  1. Ticket change [5523d8e030] (rid 206037) by anonymous on 2022-10-26 09:43:58:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      On Ubuntu 22.04 when running the following code, the application crashes with:
      wrong digit!
      Aborted (core dumped)
      
      
      #include <float.h>
      #include <limits.h>
      #include <stdlib.h>
      #include "tcl.h"
      
      Tcl_Interp *interp_ = NULL;
      
      const char *GetGlobalArray( const char *varname, const char *idx )
      {
        const char *actval = Tcl_GetVar2( interp_, varname, idx,
      				    TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG );
        if ( actval == NULL ) {
          fprintf( stderr, "Error in get %s (%s)\n", varname, idx );
          exit( 1 );
        }
        
        return actval;
      }
      
      void SetGlobalArray( const char *varname, const char *idx,
      		     double varval )
      {
        fprintf( stderr, "Set %s, %s  : %.*e\n", varname, idx, DBL_DIG, varval );
      
        Tcl_Obj *ns1 = Tcl_NewStringObj( varname, -1 );
        Tcl_IncrRefCount( ns1 );
        Tcl_Obj *ns2 = Tcl_NewStringObj( idx, -1 );
        Tcl_IncrRefCount( ns2 );
        Tcl_Obj *nd = Tcl_NewDoubleObj( varval );
        Tcl_IncrRefCount( nd );
        double foo;
        Tcl_GetDoubleFromObj( interp_, nd, &foo );
        fprintf( stderr, "Double value of object: %.*e\n", DBL_DIG, foo );
        
        Tcl_Obj *actval = Tcl_ObjSetVar2( interp_, ns1, ns2, nd,
      				    TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG );
      
        fprintf( stderr, "Content of array      : %s\n", 
      	   GetGlobalArray( varname, idx ) );
        Tcl_DecrRefCount( ns1 );
        Tcl_DecrRefCount( ns2 );
        Tcl_DecrRefCount( nd );
      }
      
      int main( int argc, const char *argv[] ) 
      {
        Tcl_FindExecutable( argv[0] );
        interp_ = Tcl_CreateInterp();
        
        Tcl_ObjSetVar2( interp_, Tcl_NewStringObj( "tcl_precision", -1 ), NULL,
        		  Tcl_NewIntObj( 17 ), TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG );
      
        double val = 6.4623485355705287e-27;
        SetGlobalArray( "some_array", "idx1", val );
        return 0;
      }
      
    5. foundin initialized to: "8.6.12"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Severe"
    11. status initialized to: "Open"
    12. submitter initialized to: "anonymous"
    13. subsystem initialized to: "10. Objects"
    14. title initialized to: "Tcl aborts with wrong digits"
    15. type initialized to: "Bug"
  2. Ticket change [3b177611f3] (rid 207978) by jan.nijtmans on 2022-12-22 15:25:19:

    1. icomment:
      This is even reproducable (kind of) at script level:
      <pre>
      % set tcl_precision 14
      14
      % expr 6.4623485355705287e-27
      6.4623485355705e-27
      % set tcl_precision 15
      15
      % expr 6.4623485355705287e-27
      %
      </pre>
      So "expr" gives the empty string when  tcl_precision>=15.
      
      Since, tcl_precision is deprecated (it's removed completely in Tcl 9.0), not high prio to fix this.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
    4. severity changed to: "Cosmetic"
  3. Ticket change [dbfd97e5d1] (rid 207979) by jan.nijtmans on 2022-12-22 15:36:34:

    1. assignee changed to: "kbk"
    2. icomment:
      Most likely, this is the TclDoubleDigits function, which was rewritten [5986a2c42150954a|here].
      
      Assigning to Kevin
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/x-fossil-wiki"
  4. Ticket change [092915b279] (rid 207983) by kbk on 2022-12-23 06:05:00:

    1. icomment:
      It's going to be a little while before I can get to this; I've got a bit of a case of "CoViD brain fog" and can't quite focus enough to debug something complicated at the moment. It's been less than a week since I came down with CoViD, so I'm hoping things will have cleared up after the holidays.
      
    2. login: "kbk"
    3. mimetype: "text/plain"
  5. Ticket change [f21f041dc3] (rid 207984) by kbk on 2022-12-23 21:02:40:

    1. icomment:
      It's going to be a little while before I can get to this; I've got a bit of a case of "CoViD brain fog" and can't quite focus enough to debug something complicated at the moment. It's been less than a week since I came down with CoViD, so I'm hoping things will have cleared up after the holidays.
      
    2. login: "kbk"
    3. mimetype: "text/plain"
  6. Ticket change [cb9f600deb] (rid 208321) by kbk on 2023-01-22 02:27:07:

    1. closedate changed to: "2459966.60216491"
    2. closer changed to: "kbk"
    3. icomment:
      There was an off-by-one in three (closely related) places in tclStrToD.c that affected 15<=tcl_precision<=18 for certain double values that were very close to overflowing intermediate results. It would take more work to explain exactly which values are affected, but 2**-87 is definitely one of them, and there's a suitable test case for 8.x.
      
      Tcl 9.x has the bug fixed, but the behaviour appears to be untestable at script level at the moment. I'll look into tidying that at some point.  If we ever get around to using Tcl_DoubleDigits in Tcl_AppendFormatToObj (which would probably be a good idea), then we'll need the same code.
      
    4. login: "kbk"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  7. Ticket change [a2b8c5d2ca] (rid 240145) by dgp on 2025-05-16 19:12:43:

    1. closedate changed to: "2460812.3005052"
    2. closer changed to: "dgp"
    3. icomment:
      
      Three tests introduced by this patch fail on a tcl/unix build
      on a macOS Sonoma 14.7.5 system, built under tcl/unix with clang 16:
      
      ==== expr-63.15.87 convert 2**-87 to decimal at precision 15 FAILED
      ==== Contents of test case:
      
                      do-one-test-expr-63 $e $p $float $athreshold
                  
      ---- Result was:
      Result 0.00000018626451e-28 is more than 5.7174648137343064e-42 away from 6.462348535570529e-27
      ---- Result should have been (exact matching):
      
      ==== expr-63.15.87 FAILED
      
      
      
      ==== expr-63.16.87 convert 2**-87 to decimal at precision 16 FAILED
      ==== Contents of test case:
      
                      do-one-test-expr-63 $e $p $float $athreshold
                  
      ---- Result was:
      Result 0.000000186264515e-28 is more than 1.2174648137343063e-42 away from 6.462348535570529e-27
      ---- Result should have been (exact matching):
      
      ==== expr-63.16.87 FAILED
      
      
      
      ==== expr-63.17.87 convert 2**-87 to decimal at precision 17 FAILED
      ==== Contents of test case:
      
                      do-one-test-expr-63 $e $p $float $athreshold
                  
      ---- Result was:
      Result 0.0000001862645149e-28 is more than 7.674648137343063e-43 away from 6.462348535570529e-27
      ---- Result should have been (exact matching):
      
      ==== expr-63.17.87 FAILED
      
      These failures continue through the current tip of the 8.6 branch
      
    4. login: "dgp"
    5. mimetype: "text/plain"
  8. Ticket change [adeacf8de7] (rid 240248) by dgp on 2025-05-20 18:36:44:

    1. closedate changed to: "2460816.27551753"
    2. icomment:
      
      It looks like the tcl/unix builds make it far too easy
      for a `make test` to test the installed library that is
      still buggy instead of testing the built library in the
      workspace which includes the fix.
      
      I think this was a false alarm.
      
    3. login: "dgp"
    4. mimetype: "text/plain"