Skip to content
Tcl Source Code History Of Ticket 2800740
Login

History Of Ticket 2800740

Artifacts Associated With Ticket 2800740

  1. Ticket change [f62b964dea] (rid 130244) by dgp on 2009-06-03 21:30:56:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      
      % set x [expr {1<<(2**31-1)}]; concat
      % set x [expr {$x<<(2**31-1)}]; concat
      % set x [expr {$x<<(2**31-1)}]; concat
      % set x [expr {$x<<(2**31-1)}]; concat
      % set x [expr {$x<<(2**31-1)}]; concat
      % set x [expr {$x<<(2**31-1)}]; concat
      % set x [expr {$x<<(2**31-1)}]; concat
      
      Program received signal SIGSEGV, Segmentation fault.
      0x000000000046dfca in TclBN_mp_grow (a=0x7fff9fd04f20, size=536870920)
          at /home/dgp/cvs/tcl8.5/unix/../libtommath/bn_mp_grow.c:48
      48            a->dp[i] = 0;
      (gdb) print a
      $1 = (mp_int *) 0x7fff9fd04f20
      (gdb) print a->dp
      $2 = (mp_digit *) 0x861fc68
      (gdb) print i
      $3 = 460175076
      (gdb) print a->alloc
      $4 = 536870920
      (gdb) print a->dp[i]
      Cannot access memory at address 0xe3cfb388
      (gdb) print size
      $5 = 536870920
      
      Suspect there's been an overflow in the
      second argument to XREALLOC() a few
      lines earlier, and we didn't really request
      as much memory as we actually need.
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "dgp"
    10. subsystem initialized to: "None"
    11. title initialized to: "libtommath crash"
    12. type initialized to: "Bug"
  2. Ticket change [3961ae391f] (rid 112378) by dgp on 2009-06-04 04:44:36:

    1. assignee changed to: "kennykb"
    2. icomment:
      
      Tcl's use of libtommath sets mp_digit
      to be 'unsigned long' which on my test
      system is 4 bytes, so sizeof(mp_digit) * size
      is 2147483680, which is bigger than INT_MAX.
      
      If something in the machinery giving meaning
      to the XREALLOC() macro tries to force it
      through a signed int, I'd expect trouble at this
      point.  Can kbk (or anyone) shed light on just
      what XREALLOC() means in this context ?
      
      
      
      
    3. login: "dgp"
    4. mimetype: "text/plain"
    5. subsystem changed to: "48. Number Handling"
    6. username: "dgp"
  3. Ticket change [c7e5099fb8] (rid 122020) by dgp on 2009-06-04 04:50:47:

    1. icomment:
      
      Yup, XREALLOC gets defined in terms of
      Tcl's ckrealloc routine which has the well
      known handicap of using signed ints for
      allocation size.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  4. Ticket change [20a078cb75] (rid 130457) by dgp on 2009-06-04 04:58:32:

    1. icomment:
      
      Hmm... perhaps not.  Tcl_Realloc() actually
      takes an "unsigned int" argument, which
      ought to still be ok.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  5. Ticket change [2c365fba6a] (rid 118861) by dgp on 2009-06-04 05:05:16:

    1. icomment:
      
      d'oh!  I wasn't on the system I thought.
      
      Where I was, sizeof(unsigned long) is 8.
      
      Hmm. on such systems, shouldn't we
      revise the mp_digit so that we don't use
      64-bit integers to store only 28 bits of
      data?
      
      I must still be missing something.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  6. Ticket change [aa6bba4591] (rid 100922) by dgp on 2009-06-05 01:25:50:

    1. icomment:
      
      confirmed.  On a Linux x86_64 system,
      Tcl's default configuration sets
      sizeof(mp_digit) to 8, so that the
      dp[] array is made up of 64-bit
      integer elements, and also sets
      DIGIT_BIT to 28, so that we are
      only using 28 out of each 64 bits
      to represent the numeric value.
      
      Over 50% waste!
      
      Some parts of the Tcl public interface
      accept (mp_int *) arguments.  Are we
      still free to change these settings without
      creating ABI incompatibilities there?
      
      Even if we are not, can we plausibly
      argue even in an 8.5.8 release that
      what we are really doing is fixing a bug
      in the implementation?  
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  7. Ticket change [9ec96a8458] (rid 96537) by dgp on 2009-06-05 01:25:51:

    1. priority changed to: "8"
  8. Ticket change [f4b6659e16] (rid 129970) by dgp on 2009-06-05 02:40:44:

    1. icomment:
      
      After unwinding the header tangle,
      the typedef that controls is the one
      found on line 2187 of tcl.h.
      
      Changing it means changing the
      public interface, at least on those
      platforms where TCL_WIDE_INT_IS_LONG
      but it still seems to me like the right
      choice to make.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  9. Ticket change [a884a527ce] (rid 99011) by dgp on 2009-06-05 03:06:55:

    1. icomment:
      
      Changing line 2187 of tcl.h to
      
      typedef unsigned int mp_digit;
      
      permits the left shifting to continue
      several more times.  On the 14th
      shift, we get the segfault again, but
      this time because the actual limits
      of the mp_int struct are being exceeded.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  10. Ticket change [1ed616140e] (rid 91048) by dgp on 2009-10-02 03:34:32:

    1. assignee changed to: "dgp"
    2. priority changed to: "9 Immediate"
  11. Ticket change [e9341eed94] (rid 104774) by dgp on 2009-10-30 01:38:48:

    1. closedate changed to: "2009-10-29T18:38:48"
    2. closer changed to: "dgp"
    3. foundin changed to: "obsolete: 8.5.7"
    4. icomment:
      
      
      allow_comments - 1
      
      
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
    9. username: "dgp"