Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: caa598dd67e11f1a70c3638726db497905b06a22e2f06e5eed5f9567c6ebc819
Ticket: 409a4e5f2853644f6e78dce8f8d0d68a0d393dde
Abstract-list hooks: lpop and join/lset crash, lindex reads before buffer with a negative index
User & Date: rocketship98 on 2026-10-18 19:08:01
Changes

  1. icomment:
    Thanks, this caused a crash in my own extension that claude helped me write and he says there's a documention gap:
    
    Addition to F1: doc/ObjectType.3 (SETELEMENT section) is silent on two points, and the core’s callers disagree on the second.
    
    lpop calls setElementProc with valueObj == NULL, meaning “remove this element”. A type written from the manual crashes on lpop l 1. A real extension (a bit-array type) segfaulted this way. The only hint is a comment in TclLsetFlat (“NULL to ‘lpop’”).
    The manual does not say who owns the reference count of the returned Tcl_Obj. lset (tclCmdIL.c ~4295) increments it, while lpop (~2670-2682) calls TclUndoRefCount on it with no prior increment, which is the bug in F1.
    
    Suggest documenting both: that valueObj may be NULL for lpop, and whether the returned object comes with a reference. The fix for F1 then follows from the stated rule.
    
  2. login: "rocketship98"
  3. mimetype: "text/plain"