Skip to content
Tcl Source Code History Of Ticket 67769bcad3b177aa
Login

History Of Ticket 67769bcad3b177aa

Artifacts Associated With Ticket 67769bcad3b177aa

  1. Ticket change [645b1b02c8] (rid 253336) by anonymous on 2026-05-07 18:11:05:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      I get the feeling that TIP59's Tcl_RegisterConfig doesn't see much use, but I rely on it to provide stubs-exporting package info to stubs-consuming jit compiled c code, to make available the info on the exporting package's library, header and other info not reliably available otherwise.  I could invent my own protocol for that but Tcl_RegisterConfig seems like the intended mechanism for that.
      
      The issue is that (in contradiction to the Tcl_RegisterConfig documentation), the supplied values *ARE* copied (which is ok, and better for my use case), but calling a second time wipes out the existing registration (after seemingly trying to merge the new info with it):
      
        1. A fresh QCCD *cdPtr_2 is allocated.                                                                                             
        2. Phase I retrieves the existing pkgDict from pDB, mutates it (or its duplicate if shared) by adding the call's new key/value
        pairs, and writes it back: pDB[pkgName] = pkgDict now contains the merged old + new entries.                                       
        3. Phase II calls Tcl_CreateObjCommand("::demopkg::pkgconfig", ..., cdPtr_2, QueryConfigDelete).
        4. Because the command already exists, TclCreateObjCommandInNs (tclBasic.c:2896) deletes the old Command via                       
        Tcl_DeleteCommandFromToken, which synchronously fires QueryConfigDelete for the old cdPtr_1.                                       
        5. That delete proc runs (tclConfig.c:324-338):                                                                                    
        Tcl_DictObjRemove(NULL, pDB, pkgName);   // removes the merged dict we just put in!                                                
        Tcl_DecrRefCount(pkgName);                                                                                                         
        Tcl_Free(cdPtr->encoding);                                                                                                         
        Tcl_Free(cdPtr);                                                                                                                   
        6. The merged sub-dict's refcount drops to zero, freeing all the byte-array value copies and string-key copies from both the first 
        and second calls.                                                                                                                  
        7. The new command is then created bound to cdPtr_2, but pDB has no entry for pkgName any more.
      
      Could the sequence be changed so that the second Tcl_RegisterConfig call does the unsurprising thing and merges in the passed config keys?
      
      Verified in 8.6 and 9.0
      
    5. foundin initialized to: "8.6-9.0"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "anonymous"
    13. subsystem initialized to: "54. Configuration Reporting"
    14. title initialized to: "Tcl_RegisterConfig idempotency issue"
    15. type initialized to: "Bug"
  2. Ticket change [c81fd5da52] (rid 259559) by serhiy.storchaka on 2026-10-20 18:53:13:

    1. foundin changed to: "8.6.18, 9.0.5, 9.1.0"
    2. icomment:
      Confirmed on main, 9.0 and 8.6; your analysis is right: creating the new <code>pkgconfig</code> command deletes the old one, and its QueryConfigDelete removes the just merged package dict.
      
      Proposed fix in branch [d9ca7f22fe|registerconfig-twice]: keep a reference to the merged dict and put it back after the command is created. RegConfig.3 now says that a second call adds its keys (and replaces the values of existing ones). New test pkgconfig-3.1, using a new <code>testregisterconfig</code> command.
      
    3. login: "serhiy.storchaka"
    4. mimetype: "text/x-fossil-wiki"