Skip to content
Tcl Source Code History Of Ticket 1851832fffffffffffffffffffffffffffffffff
Login

History Of Ticket 1851832fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 1851832fffffffffffffffffffffffffffffffff

  1. Ticket change [dab00deda9] (rid 107833) by msofer on 2007-12-16 12:53:10:

    1. assignee initialized to: "hobbs"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      While investigating [Bug 1851524] I noticed that Tcl's memory allocators may not be doing the right thing wrt alignment of the allocated memory:
      
      - TclStackAlloc returns a pointer to a memory address that is aligned to a multiple of sizeof(void *): 4-byte alignment on 32b platforms, 8-byte on 64b
      
      - Tcl_Alloc returns 16-aligned memory on apple, 8-aligned otherwise (ALLOCALIGN macros defined both in tclAlloc.c and tclThreadAlloc.c)
      
      - other platforms than apple (especially 64b) require 16-byte alignment (see eg http://msdn2.microsoft.com/en-us/library/ycsb6wwf(VS.80).aspx)
      
    4. foundin initialized to: "obsolete: 8.5b3"
    5. is_private initialized to: "0"
    6. priority initialized to: "9 Immediate"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "msofer"
    10. subsystem initialized to: "41. Memory Allocation"
    11. title initialized to: "badly aligned mem allocations?"
    12. type initialized to: "Bug"
  2. Ticket change [a6ec30c3a5] (rid 98691) by msofer on 2007-12-16 19:59:18:

    1. icomment:
      Logged In: YES 
      user_id=148712
      Originator: YES
      
      "The address of a block returned by malloc or realloc in the GNU system is always a multiple of eight (or sixteen on 64-bit systems)"
      (from http://www.delorie.com/gnu/docs/glibc/libc_31.html)
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  3. Ticket change [dce58aef35] (rid 114566) by msofer on 2007-12-16 20:15:33:

    1. icomment:
      Logged In: YES 
      user_id=148712
      Originator: YES
      
      To be determined: the macro TCL_ALIGN (used in the bytecode compiler and tbcload) currently insures 8-byte alignment; shouldn't it also be platform specific?
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  4. Ticket change [d67c621d89] (rid 123814) by msofer on 2007-12-17 02:01:23:

    1. icomment:
      
      
      File Added - 258791: alloc.patch
      
      Logged In: YES 
      user_id=148712
      Originator: YES
      
      Attaching a patch that insures that TclStackAlloc uses the same alignment as Tcl_Alloc. The ALLOCALIGN macros are unified in tclInt.h as TCL_ALLOCALIGN. 
      
      Still to do:
      (a) test the patch on 64b platforms (did I do something stupid?)
      (b) fix the TCL_ALLOCALIGN macros for the different platforms
      File Added: alloc.patch
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  5. Ticket change [7161dd289c] (rid 100663) by msofer on 2007-12-17 02:28:12:

    1. icomment:
      
      
      File Added - 258792: alloc.patch
      
      Logged In: YES 
      user_id=148712
      Originator: YES
      
      File Added: alloc.patch
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  6. Ticket change [15042a7c32] (rid 124494) by msofer on 2007-12-17 02:28:13:

    1. icomment:
      
      
      File Deleted - 258791: 
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  7. Add attachment "alloc.patch" [2d2e19689b] (rid 119028) by msofer on 2007-12-17 04:27:10.

  8. Ticket change [1dbe67fb45] (rid 90863) by msofer on 2007-12-17 04:27:11:

    1. icomment:
      
      
      File Deleted - 258792: 
      
      
      
      File Added - 258809: alloc.patch
      
      Logged In: YES 
      user_id=148712
      Originator: YES
      
      File Added: alloc.patch
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  9. Ticket change [3e828436bc] (rid 121281) by hobbs on 2007-12-17 06:14:21:

    1. assignee changed to: "dgp"
    2. icomment:
      Logged In: YES 
      user_id=72656
      Originator: NO
      
      Passing to dgp as the primary author (?) of the TclStackAlloc changes.  Using the 8.5.0 RC, I forced a USE_TCLALLOC Linux-x64 build and built standard opts on HP-UX PA-RISC with 64-bit enabled and was not able to trigger this bug.  For that reason I moved it down to prio 8 - odd platform/compiler combo.(?)
      
      
    3. login: "hobbs"
    4. mimetype: "text/plain"
    5. priority changed to: "8"
    6. username: "hobbs"
  10. Add attachment "alloc2.patch" [e2a0be98da] (rid 87664) by msofer on 2007-12-17 19:21:06.

  11. Ticket change [f3472de19e] (rid 129681) by msofer on 2007-12-17 19:21:06:

    1. icomment:
      
      
      File Added - 258873: alloc2.patch
      
      Logged In: YES 
      user_id=148712
      Originator: YES
      
      An alternative fix for TclStackAlloc to always return 2-word aligned memory independently of whatever Tcl_Alloc does (ie, without looking at ALLOCALIGN or touching Tcl_Alloc) is attached as alloc2.patch.
      
      Looking at TclpAlloc in more detail, I now see that the bug is "there but not there": struct Block contains a (Block *) and a size_t - on usual platforms, it is 2-word wide. The ALLOCALIGN=8 padding is only really functional on platforms where 2 words are less than 8 bytes (ie, on 16b platforms?); otherwise sizeof(Block) is 8 on 32b and 16 on 64b. The blocks themselves start at multiples of MINALLOC (16 resp 32) away from something returned by malloc, and the Tcl_Alloc'ed memory is computed in Block2Ptr as '(char *)(blockPtr+1)'.
      
      All of this means that the alignment of Tcl_Alloc is not actually ALLOCALIGN=8 on 64b platforms, but rather 16. Setting it to 16 will not change anything in Tcl_Alloc, but "fix" the (patched with alloc.patch) TclStackAlloc and make the actual alignment of Tcl_Alloc clearer.
      
      File Added: alloc2.patch
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  12. Add attachment "alloc3.patch" [9656ed0b61] (rid 106308) by msofer on 2007-12-17 20:44:57.

  13. Ticket change [4aefacd94b] (rid 126618) by msofer on 2007-12-17 20:44:57:

    1. icomment:
      
      
      File Added - 258880: alloc3.patch
      
      Logged In: YES 
      user_id=148712
      Originator: YES
      
      New patch alloc3.patch - previous patches removed. It sets TCL_ALLOCALIGN to 2*sizeof(void *) (or 16 for apple, as before), mimicking what gnu's malloc does. Note that the value is still 8 on 32b, but is now 16 on 64b. Both Tcl_Alloc and TclStackAlloc respect now the alignment reqs.
      File Added: alloc3.patch
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  14. Ticket change [c821460b16] (rid 122058) by dgp on 2007-12-17 23:02:13:

    1. assignee changed to: "msofer"
  15. Ticket change [25d9f267e6] (rid 88234) by msofer on 2007-12-17 23:08:51:

    1. closedate changed to: "2007-12-17T16:08:51"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      Originator: YES
      
      Patch committed to HEAD
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "msofer"