Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 452a317ccbce7ce937abb49f65e1b2d3ac965492a144e4b18230861eee90582b
Ticket: 5ee01098824881b5500e4692bcfa74eb853bc795
lseq list conversion results in attempt to access freed memory
User & Date: pooryorick on 2023-05-17 11:50:56
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    In a build of trunk with --enable-symbols and CFLAGS="-DPURIFY", the following script
    
    <blockquote><code><verbatim>
    trace add variable one write [list ::apply [list args {
    	error {this error}
    } [namespace current]]]
    set one [lindex [lreplace [lseq 1 2] 1 1 hello] 0]
    </verbatim></code></blockquote>
    
    Results in the following error:
    
    <blockquote><code><verbatim>
    malloc(): unaligned fastbin chunk detected 3
    </verbatim></code></blockquote>
    
    The reason is that <code>lreplace</code> converts the internal repesentation
    from <code>tclArithSeriesType</code> to <cod>tclListType</code>, and
    <code>SetListFromAny()</code> handles the arithmetic series specially,
    forgetting to increment the reference count when each <code>Tcl_Obj</code> is
    added to the list.  See
    [https://core.tcl-lang.org/tcl/file?udc=1&ln=3323&ci=57e46213e1e5414a&name=generic%2FtclListObj.c|this
    loop].
    
  5. is_private changed to: "0"
  6. login: "pooryorick"
  7. priority changed to: "5 Medium"
  8. private_contact changed to: "2b2275eab1118e1fab0016cf1c5702893c6af86c"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "pooryorick"
  13. subsystem changed to: "- New Builtin Commands"
  14. title changed to:
    lseq list conversion results in attempt to access freed memory
    
  15. type changed to: "Bug"