Artifacts Associated With Ticket 6d4e9d1af5
Ticket change [fe01f173f4] (rid 210944) by pooryorick on 2023-03-26 10:30:33:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
[https://core.tcl-lang.org/tcl/file?udc=1&ln=2359&ci=c02747a663bc158a&name=generic%2FtclPathObj.c|SetFsPathFromAny] duplicates a Tcl_Obj and then stores a pointer to the new object in a fsPathPtr, which it then sets as the internal representation of another Tcl_Obj, pathPtr. Because no care is taken to ensure that the internal representation of the newly-duplicated Tcl_Obj contains no reference-counted copy of pathPtr, it's possible for a situation to arise where pathPtr contains a pointer to itself, and that its reference count therefore never drops to 0, which is a memory leak. In test Tcl_Main-2.1 such a situation does in fact occur: "result" is a literal value that, by the time SetFsPathFromAny receives it, has already been entered into the literalTable of the interpreter, and has also received an internal representation of type "localVarNameType", possibly due to its appearance in procedures within msgcat.tcl. When pathPtr is duplicated, DupLocalVarName() [https://core.tcl-lang.org/tcl/file?udc=1&ln=5809&ci=c02747a663bc158a&name=generic%2FtclVar.c|makes pathPtr the internal representation of the duplicated object], transPtr. Then transPtr is stored in fsPathPtr, which becomtes the internal representation of pathPtr. Valgrind reports still-reachable blocks due to this situation, but only when all other tests are deleted from the source file. Although this issue can be fixed by modifying SetFsPathFromAny, it is yet another example of how sharing a single Tcl_Obj between identical literal values causes trouble. First, it creates a situation where there is only one internal representation even though the identical literal values may have different contexts and interpretations. Second, it makes errors like this one, which can go undiscovered for years, more likely.
- is_private initialized to: "0"
- login: "pooryorick"
- priority initialized to: "5 Medium"
- private_contact initialized to: "2b2275eab1118e1fab0016cf1c5702893c6af86c"
- resolution initialized to: "None"
- severity initialized to: "Critical"
- status initialized to: "Open"
- submitter initialized to: "pooryorick"
- subsystem initialized to: "36. Pathname Management"
- title initialized to:
memory leak: SetFsPathFromAny, assisted by the global literal table, causes a Tcl_Obj to reference itself
- type initialized to: "Bug"
Ticket change [b66403dab9] (rid 210945) by pooryorick on 2023-03-26 10:30:48:
- assignee changed to: "pooryorick"
- login: "pooryorick"
- mimetype: "text/plain"
Ticket change [55234a87f2] (rid 210955) by pooryorick on 2023-03-26 15:08:55:
- icomment: "Fixed in [1ec9da4c469c29f4]."
- login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
Ticket change [dab9b2e1cc] (rid 210956) by pooryorick on 2023-03-26 15:10:33:
- icomment: "Correction: Fixed in [a9c542391a86a9e8]."
- login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Pending"
Ticket change [6c163527d5] (rid 212961) by pooryorick on 2023-04-15 21:28:55:
- closedate changed to: "2460050.39508404"
- closer changed to: "pooryorick"
- login: "pooryorick"
- mimetype: "text/plain"
- status changed to: "Closed"