Artifacts Associated With Ticket ae09f6b190
Ticket change [cd4fbfb60a] (rid 228603) by pointsman on 2024-07-14 01:04:34:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-plain"
- comment initialized to:
The commit https://core.tcl-lang.org/tcl/info/bacfccf1e2cbab78 introduced a memory leak. While I understand the reasoning for [bacfccf1e2cbab78] I so far not understand why it had this unfortunate "side-effect". The builds I use for this are all made with -DPURIFY. I'll append the output of a "make valgrind" run with [95f9e8176ed0b552] - the parent commit of bacfccf1e2cbab78 - and the output of the same with current trunk as of writing ([08603ee649]). The output of "make valgrind" with [bacfccf1e2cbab78] looks similar to the one of [08603ee649] (current trunk). For a short verification you don't need the whole time consuming run of the test suite under valgrind. With [bacfccf1e2cbab78] and under linux make valgrind TESTFLAGS='-file load.test' it returns (amongst more details) definitely lost: 80 bytes in 5 blocks indirectly lost: 176 bytes in 11 blocks possibly lost: 0 bytes in 0 blocks still reachable: 0 bytes in 0 blocks suppressed: 0 bytes in 0 blocks With [95f9e8176ed0b552] - the parent commit of bacfccf1e2cbab78 - and the same make valgrind TESTFLAGS='-file load.test' it returns HEAP SUMMARY: in use at exit: 0 bytes in 0 blocks total heap usage: 383,994 allocs, 383,994 frees, 43,997,079 bytes allocated All heap blocks were freed -- no leaks are possible This can easily be "exploited" by a script. Any Tcl 9 binary extension will do it (I'd suppose). In the example below I used tdom de5237af97f2c1c (trunk at the moment of writing this). Run (your moral equivalent) of load ./libtcl9tdom0.9.4.so while 1 { interp create childinterp load {} Tdom childinterp interp delete childinterp } with a [bacfccf1e2cbab78] tclsh and watch the process somewhat slowly but steady growing. If I run that script with a tclsh with the parent commit to that the process doesn't shows this. (At least with mem builds.) Neither do I see the problem with 8.6 - foundin initialized to: "Tcl 9"
- is_private initialized to: "0"
- login: "pointsman"
- priority initialized to: "5 Medium"
- private_contact initialized to: "4ca203a8e925aecdd9419645f936bccf18cd6ea7"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "pointsman"
- subsystem initialized to: "- New Builtin Commands"
- title initialized to: "Mem leak in trunk"
- type initialized to: "Bug"
Add attachment "valgrind-95f9e8176e.out" [691d598136] (rid 228605) by pointsman on 2024-07-14 01:05:39.
Add attachment "valgrind-08603ee649.out" [40ac42308f] (rid 228607) by pointsman on 2024-07-14 01:06:02.
Ticket change [81645c6200] (rid 228647) by sebres on 2024-07-14 23:57:19:
- icomment:
The reason for the side effect is pretty simple - LoadCleanupProc uses Tcl_GetAssocData internally [.//info?name=288f7d23cad3c599d0840c5467616bcc9eb6ecc940c870210f413870e52fdfd0&ln=1217-1220|here] and because the hash entry is already removed, it gets NULL and so the clean-up doesn't invoke unload below and therefore leaking. Strange is that this was never noticed in 8.6, which was not affected by [34870ab5756911d1] and the hash entry removal were there before the call of the clean-up proc initially. I'll try to fix it if I identify all affected branches.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [d8f1164ffb] (rid 228652) by sebres on 2024-07-15 01:22:57:
- closedate changed to: "2460506.55761219"
- closer changed to: "sebres"
- foundin changed to: "8.7+"
- icomment:
Fixed in [24ace090aad63399] for 8.7 and merged to 9.0.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [13c6b9f620] (rid 228674) by oehhar on 2024-07-15 19:49:21:
- closedate changed to: "2460507.32594037"
- closer changed to: "oehhar"
- icomment:
Sergey, great work ! Could you look into ticket [a7b7dd7927] which reports a segfault supposed to be caused by the fix? Thanks for all, Harald
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"