Skip to content
Tcl Source Code History Of Ticket e8b18d7b1fbe160a
Login

History Of Ticket e8b18d7b1fbe160a

Artifacts Associated With Ticket e8b18d7b1fbe160a

  1. Ticket change [e3b4cb9856] (rid 241634) by apnadkarni on 2025-06-18 07:59:59:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      Both the mentioned functions have error paths that fail to call Tcl_EncodingFree on the retrieved Tcl_Encoding.
      
      The Tcl_Encoding structures are reference counted so there is no observable memory growth no matter how many times the error path is taken hence marked as Minor. But the resources are effectively never freed if there are encoding errors even if the encoding is no longer needed.
      
    5. foundin initialized to: "9.0"
    6. is_private initialized to: "0"
    7. login: "apnadkarni"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "9546e9877f1a8899e25a89082561ee694e7fb402"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "apnadkarni"
    14. subsystem initialized to: "- New Builtin Commands"
    15. title initialized to:
      EncodingConvert{to,from}ObjCmd do not free Tcl_Encoding on error paths
      
    16. type initialized to: "Bug"
  2. Ticket change [d3ea537824] (rid 241635) by apnadkarni on 2025-06-18 08:00:12:

    1. assignee changed to: "apnadkarni"
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  3. Ticket change [008e1f9d01] (rid 241647) by dgp on 2025-06-18 12:52:30:

    1. icomment:
      Just a word of caution.  I'd have to refresh to get the details right
      but I believe there is some care taken to avoid release of Tcl_Encoding
      because many of them have to be brought in from disk, and a program that
      gets in a cycle of load-use-discard will not be as happy as if it just
      holds on to a loaded encoding it is likely to use again.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  4. Ticket change [41c40a341b] (rid 241648) by apnadkarni on 2025-06-18 14:08:38:

    1. icomment:
      Appreciate the warning but I am indeed aware of the loading and caching mechanism for encodings. However, note that
      
      * The success case does in fact call `Tcl_FreeEncoding` but the error case does not. This inconsistency does not make sense if the goal is to keep encodings in memory.
      
      * The functions in question actually use `Tcl_GetEncodingFromObj` which in effect adds an extra reference count for exactly that reason. Even with a `Tcl_FreeEncoding` it will stay in memory until the caching `Tcl_Obj` is freed or shimmered. So for instance when the encoding name is within a proc, it will effectively keep in the encoding in memory as long as the proc's bytecode exists.
      
      * As an aside, there is a non-trivial amount of code that deals with caching of encoding with a shared table and mutex access. So I presume at some point it was thought to be important to discard encoding tables. I am not sure what was considered a lot of memory three decades ago is true anymore and at some point it might be worth looking at never releasing loaded encodings, thereby both simplifying the code and more efficient encoding operations by avoiding the locks and cache flushes.
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  5. Ticket change [52c2b98e84] (rid 241797) by apnadkarni on 2025-06-20 16:09:56:

    1. closedate changed to: "2460847.17356809"
    2. closer changed to: "apnadkarni"
    3. icomment: "Fixed in [77100b263a]."
    4. login: "apnadkarni"
    5. mimetype: "text/x-fossil-plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"