Overview
| Artifact ID: | 645b1b02c842038608acdfc5bb01dc14dfdcc3ec486233132c99366f3cbb8ad5 |
|---|---|
| Ticket: | 67769bcad3b177aaf9474f8d0a07c2242a18a7f1
Tcl_RegisterConfig idempotency issue |
| User & Date: | anonymous on 2026-05-07 18:11:05 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-plain"
- comment changed 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 - foundin changed to: "8.6-9.0"
- is_private changed to: "0"
- login: "anonymous"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "anonymous"
- subsystem changed to: "54. Configuration Reporting"
- title changed to: "Tcl_RegisterConfig idempotency issue"
- type changed to: "Bug"