Artifacts Associated With Ticket 8259d74a649c4e93
Ticket change [fefc9e01dd] (rid 217938) by apnadkarni on 2023-09-11 03:35:10:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-markdown"
- comment initialized to:
Exiting tclsh with an open handle to a file within a zipfs mount causes Tcl to panic. ``` % zipfs mount ../tests/zipfiles/test.zip //zipfs:/test % set fd [open //zipfs:/test/test] zipfs_37_1 % exit tried to unmount busy filesystem ```
- foundin initialized to: "8.7"
- is_private initialized to: "0"
- login: "apnadkarni"
- priority initialized to: "5 Medium"
- private_contact initialized to: "9546e9877f1a8899e25a89082561ee694e7fb402"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "apnadkarni"
- subsystem initialized to: "- New Builtin Commands"
- title initialized to: "Tcl panic on exit if zipfs file is open"
- type initialized to: "Bug"
Ticket change [12c5017288] (rid 218638) by apnadkarni on 2023-09-24 03:41:32:
- icomment: "Possibly caused by an attempt to fix [ba8845d272]"
- login: "apnadkarni"
- mimetype: "text/x-fossil-plain"
Ticket change [b5fff10681] (rid 218941) by apnadkarni on 2023-09-30 03:59:09:
- closedate changed to: "2460217.66607941"
- closer changed to: "apnadkarni"
- icomment:
Fixed in [a6562fe64a](https://core.tcl-lang.org/tcl/info/a6562fe64ac39b51). A longer term issue is that mountable file systems should be called after channels are closed in `TclFinalizeIOSubSystem`. However, there is no provision for doing so as exit handlers execute before. Because zipfs is in the core, this was fixed by removing the zipfs exit handlers and adding an explicit call to the zipfs finalization function from TFIOSS after channels are closed. For extensions that implement loadable modules it seems to me that an additional function needs to be added to `Tcl_FileSystem` dispatch table that is invoked as part of TFIOSS. That needs to be a future TIP.
- login: "apnadkarni"
- mimetype: "text/x-markdown"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [f5b74d16a9] (rid 219003) by dgp on 2023-10-02 14:43:43:
- closedate changed to: "2460220.11369758"
- closer changed to: "dgp"
- icomment:
Checkin [a6562fe64a] contains new memory corruption crashes reported by the test suite. One example error message is: Test file error: low guard byte 0 is 0x0 low guard byte 1 is 0x0 low guard byte 2 is 0x0 low guard byte 3 is 0x0 low guard byte 4 is 0x0 low guard byte 5 is 0x0 low guard byte 6 is 0x0 low guard byte 7 is 0x0 low guard byte 8 is 0x0 low guard byte 9 is 0x0 low guard byte 10 is 0x0 low guard byte 11 is 0x0 total mallocs 3985674 total frees 3959526 current packets allocated 26148 current bytes allocated 1511608 maximum packets allocated 65066 maximum bytes allocated 5607380 low guard failed at 0x102f108, /home/dgp/fossil/tcl8.7/generic/tclZipfs.c 6261 4 bytes allocated at (/home/dgp/fossil/tcl8.7/generic/tclObj.c 1786) Memory validation failure
- login: "dgp"
- mimetype: "text/plain"
Ticket change [d40b5b37ae] (rid 219004) by apnadkarni on 2023-10-02 16:19:36:
- closedate changed to: "2460220.18028183"
- closer changed to: "apnadkarni"
- icomment:
Don, What build configuration are you using? I run the following combinations on Linux and Windows before commits and none showed the error you are seeing. Linux: ``` ../configure CFLAGS=-DPURIFY --enable-symbols && make clean && make valgrind and rm -rf * && ../configure --enable-symbols=mem && make test ``` On Windows ``` nmake /f makefile.vc STATS=memdbg ``` I thought that would suffice to catch these kinds of errors. I reran the above again on core-8-branch as well as that specific commit and still don't see the errors. If you can post the specific configuration and make command, I'll try that. /Ashok
- login: "apnadkarni"
- mimetype: "text/x-markdown"
Ticket change [fe6bb8d635] (rid 219009) by dgp on 2023-10-02 16:55:41:
- closedate changed to: "2460220.20534065"
- closer changed to: "dgp"
- icomment:
$ fossil status ... checkout: a6562fe64ac39b51b8ba05dbf31f77ba8be27a70 2023-09-30 03:23:45 UTC ... comment: Fix [8259d74a64] - panic on exit (user: apnadkarni) $ ../unix/configure --disable-shared --enable-symbols=mem ... $ make test-tcl TESTFLAGS="-file unixNotfy.test" ... unixNotfy.test Test file error: low guard byte 0 is 0x0 low guard byte 1 is 0x0 low guard byte 2 is 0x0 low guard byte 3 is 0x0 low guard byte 4 is 0x0 low guard byte 5 is 0x0 low guard byte 6 is 0x0 low guard byte 7 is 0x0 low guard byte 8 is 0x0 low guard byte 9 is 0x0 low guard byte 10 is 0x0 low guard byte 11 is 0x0 total mallocs 1068301 total frees 1043382 current packets allocated 24919 current bytes allocated 1427710 maximum packets allocated 33968 maximum bytes allocated 1969189 low guard failed at 0x7f50d80e3068, /home/dgp/fossil/tcl8.7/generic/tclZipfs.c 6261 6 bytes allocated at (/home/dgp/fossil/tcl8.7/generic/tclZipfs.c 2151) Memory validation failure Tests ended at Mon Oct 02 12:51:17 EDT 2023 all.tcl: Total 4 Passed 2 Skipped 2 Failed 0 Sourced 1 Test Files. Number of tests skipped for each constraint: 2 nonPortable Test files exiting with errors: unixNotfy.test - login: "dgp"
- mimetype: "text/plain"
Ticket change [340999e721] (rid 219010) by apnadkarni on 2023-10-02 17:16:22:
- closedate changed to: "2460220.21970625"
- closer changed to: "apnadkarni"
- icomment:
OK, I see at least one difference in environment. You have the Thread package available, I don't and neither does github actions. Will try installing the package tomorrow and retry. Could you please post the version of Thread that you have? I'd prefer to clone your environment as closely as possible to reproduce the issue. /Ashok
- login: "apnadkarni"
- mimetype: "text/plain"
Ticket change [252ea4ac8b] (rid 219011) by dgp on 2023-10-02 17:23:43:
- closedate changed to: "2460220.2248034"
- closer changed to: "dgp"
- icomment:
$ fossil status ... checkout: 6088b582180f46d5caee900d5e8f7a19348b8c49 2023-09-11 15:29:15 UTC ... tags: thread-2-8-branch comment: No longer support "utf16" build mode (not used by Thread anyway)
- login: "dgp"
- mimetype: "text/plain"
Ticket change [2cca60dfa4] (rid 219012) by apnadkarni on 2023-10-02 17:38:08:
- closedate changed to: "2460220.23481808"
- closer changed to: "apnadkarni"
- icomment:
I *think* I know what the problem is. The undocumented `tcl::zipfs::fallbackEntryEncoding` variable is linked via `Tcl_LinkVar` to the global `ZipFS.fallbackEntryEncoding` C variable at initialization and then freed twice (once by each thread). I'm also not sure if it is valid to `Tcl_LinkVar` to the same `TCL_STRING_VALUE` from two different threads. Seems to me that is a race condition. I'll attempt to reproduce to confirm that is the issue before fixing. (Previous to that commit, the string was not being freed at all on exit.)
- login: "apnadkarni"
- mimetype: "text/x-markdown"
Ticket change [0bfb115c8e] (rid 219019) by apnadkarni on 2023-10-03 04:18:10:
- closedate changed to: "2460220.6792938"
- icomment:
Reproduced and fixed in branch apn-memory-fix. Building with threads does show the following errors: ``` ==== Test with ThreadLevel 2 ==== Test file error: http.test bgerror invalid command name "::http::104--SocketCoroutine" invalid command name "::http::104--SocketCoroutine" while executing "::http::104--SocketCoroutine" ("after" script) http.test bgerror invalid command name "::http::158--SocketCoroutine" invalid command name "::http::158--SocketCoroutine" while executing "::http::158--SocketCoroutine" ("after" script) Tests ended at Tue Oct 03 09:20:13 IST 2023 all.tcl: Total 528 Passed 522 Skipped 6 Failed 0 Sourced 1 Test Files. Number of tests skipped for each constraint: 3 knownBug 3 nonPortable Test files exiting with errors: http.test ``` However, these also show up in commit [b3c4b1cf907] prior to the original fix for the panic so I presume they are unrelated. As an aside, I believe there are other potential multithreading issues in zipfs that need to be looked at once the basic fixes are done. - login: "apnadkarni"
- mimetype: "text/x-markdown"
Ticket change [afb9995234] (rid 219022) by apnadkarni on 2023-10-03 05:40:20:
- closedate changed to: "2460220.73634999"
- icomment: "Merged fix into [e232836cee]."
- login: "apnadkarni"
- mimetype: "text/plain"