Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f3472de19eb7da8eb4f5cf27799c5b41b3a216bc
Ticket: 1851832fffffffffffffffffffffffffffffffff
badly aligned mem allocations?
User & Date: msofer on 2007-12-17 19:21:06
Changes

  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"