Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 289c40752fa5c430e92c839a2b2fca0f6a8683f3b1d86401c518fbf02a448b1e
Ticket: 48150cdad29ca6c6db7c1d0c86a18110dfe43d40
Command creation with overwrite (prevention against endless loop by its recreation via trace) is affected by drastic mem-leak
User & Date: sebres on 2025-03-27 13:04:53
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    The way how command gets (re)created is affected by drastic mem-leak, due to prevention against endless loop by its recreation via trace.
    The responsible place of code in [./info?udc=1&ln=on&name=4cbbfb800129c37a075b6165c9cfa6bb9d9c005f2a9583c9008c0869e0ed7d62&ln=2426-2434|TclCreateObjCommandInNs], the same is valid for other functions like Tcl_CreateCommand etc.
    
    PoC:
    <code><pre>
      namespace eval A { proc test {} {puts test}; namespace export test }
      proc recreate {args} { namespace eval ::B {
        namespace import ::A::test }; 
        trace add command ::B::test delete recreate
      }
      timerate { recreate; proc ::B::test {} {}; rename ::B::test {} } 10000
    </pre></code>
    (and lets grow the mem-usage)
    
    By regular deletion it'd restore everything back, but not by overwrite, that wins and this prevention causes that the new command overwrites the old at any cost without proper clean-up, no traces but also no deletion callback, no release for internal members, nothing excepting ckfree for cmdPtr.
    
    I'd rather expects that 2nd run of trace is avoided and the command gets deleted and overwritten properly (and surely without the leak).
    Also if command gets restored again now via deletion callback, it shall win and attempt overwrite must cause something like "cannot create - existing command restored after deletion, avoid endless loop".
    
  5. foundin changed to: "any"
  6. is_private changed to: "0"
  7. login: "sebres"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "50e9528765c18296566374b3fde2df942c394efd"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "sebres"
  14. subsystem changed to: "46. Traces"
  15. title changed to:
    Command creation with overwrite (prevention against endless loop by its recreation via trace) is affected by drastic mem-leak
    
  16. type changed to: "Bug"