Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 3f9364b0dcefbdb0f917c4babe1c6d571f019e60
Ticket: 2184717fffffffffffffffffffffffffffffffff
unaligned malloc() -> Tcl panic
User & Date: dgp on 2008-10-21 15:28:14
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    Testing memory hygiene in a program that
    embeds Tcl on an x86_64 system with
    ElectricFence, we encountered panics
    in the Tcl library.
    
    The problem boils down to this.  Tcl's
    Tcl_Alloc() routine (and the ckalloc()
    form) is documented to return a pointer
    aligned for any purpose.  Some of the
    Tcl source code is written assuming this
    to be true.
    
    Unfortunately, when malloc() returns a
    pointer that is misaligned for some
    purposes (notably for holding a pointer
    value), the TclpAlloc() implementation
    in tclThreadAlloc.c propagates that
    misalignment up to the pointer returned
    by ckalloc() leading to panics in the
    code that assumes this cannot happen.
    
    Misaligned malloc() returns is one of
    the hazards introduced by ElectricFence
    testing.
    
    Since Tcl_Alloc() is documented to return
    an aligned pointer, and it cannot always
    be assumed that malloc() will cooperate,
    it would make Tcl more robust, and more
    useful for testing in partnership with
    ElectricFence, if the allocator in
    tclThreadAlloc.c included safeguards to
    prevent misalignment from bubbling up
    from below.
    
  4. foundin changed to: "obsolete: 8.5.5"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "dgp"
  10. subsystem changed to: "41. Memory Allocation"
  11. title changed to: "unaligned malloc() -> Tcl panic"
  12. type changed to: "Bug"