Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 19c1d1f44e92c0fb546d82eb2034cf094e8075f5
Ticket: 2184717fffffffffffffffffffffffffffffffff
unaligned malloc() -> Tcl panic
User & Date: dgp on 2014-10-09 16:29:13
Changes

  1. assignee changed to: "dgp"
  2. closedate changed to: "2456940.18696495"
  3. closer changed to: "dgp"
  4. 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.
    
  5. login: "dgp"
  6. mimetype: "text/plain"
  7. resolution changed to: "Invalid"
  8. severity changed to: "Minor"
  9. status changed to: "Closed"