|
2024-08-22
| ||
| 17:31 | Merge [4b6e7cee809ab2a1]: Fix [8259d74a64], Tcl panic on exit if zipfs file is open. check-in: fa7a77e8a6 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE | |
| 17:28 | Merge [a48f311a78ac1e10]: Fix [8259d74a64] - panic on exit. check-in: 058c4f85e6 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE | |
|
2023-10-03
| ||
| 05:40 | • Ticket [8259d74a64] Tcl panic on exit if zipfs file is open status still Clo... artifact: afb9995234 user: apnadkarni | |
| 05:34 | Fix [8259d74a64] fix check-in: 4b6e7cee80 user: apnadkarni tags: trunk, main | |
| 05:00 | Fix [8259d74a64] fix check-in: e232836cee user: apnadkarni tags: core-8-branch | |
| 04:18 | • Ticket [8259d74a64] Tcl panic on exit if zipfs file is open status still Clo... artifact: 0bfb115c8e user: apnadkarni | |
| 03:28 | Fix [8259d74a64] fix closed check-in: 0824f03e05 user: apnadkarni tags: apn-memory-fix | |
|
2023-10-02
| ||
| 17:38 | • Ticket [8259d74a64] Tcl panic on exit if zipfs file is open status still Clo... artifact: 2cca60dfa4 user: apnadkarni | |
| 17:23 | • Ticket [8259d74a64]: 5 changes artifact: 252ea4ac8b user: dgp | |
| 17:16 | • Ticket [8259d74a64]: 5 changes artifact: 340999e721 user: apnadkarni | |
| 16:55 | • Ticket [8259d74a64]: 5 changes artifact: fe6bb8d635 user: dgp | |
| 16:19 | • Ticket [8259d74a64]: 5 changes artifact: d40b5b37ae user: apnadkarni | |
| 14:43 | • Ticket [8259d74a64]: 5 changes artifact: f5b74d16a9 user: dgp | |
|
2023-09-30
| ||
| 03:59 | • Closed ticket [8259d74a64]. artifact: b5fff10681 user: apnadkarni | |
| 03:51 | Merge 8.7 - Fix [8259d74a64] - panic on exit check-in: a48f311a78 user: apnadkarni tags: trunk, main | |
| 03:23 | Fix [8259d74a64] - panic on exit check-in: a6562fe64a user: apnadkarni tags: core-8-branch | |
|
2023-09-24
| ||
| 03:41 | • Ticket [8259d74a64] Tcl panic on exit if zipfs file is open status still Ope... artifact: 12c5017288 user: apnadkarni | |
|
2023-09-11
| ||
| 03:35 | • New ticket [8259d74a64]. artifact: fefc9e01dd user: apnadkarni | |
Tcl panic on exit if zipfs file is open
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
fa7a77e8a6Merge [4b6e7cee809ab2a1]: Fix [8259d74a64], Tcl panic on exit if zipfs file is open. check-in2024-08-22 17:31:15058c4f85e6Merge [a48f311a78ac1e10]: Fix [8259d74a64] - panic on exit. check-in2024-08-22 17:28:114b6e7cee80Fix [8259d74a64] fix check-in2023-10-03 05:34:00e232836ceeFix [8259d74a64] fix check-in2023-10-03 05:00:410824f03e05Fix [8259d74a64] fix check-in2023-10-03 03:28:03a48f311a78Merge 8.7 - Fix [8259d74a64] - panic on exit check-in2023-09-30 03:51:40a6562fe64aFix [8259d74a64] - panic on exit check-in2023-09-30 03:23:45
Possibly caused by an attempt to fix [ba8845d272]
Fixed in a6562fe64a.
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.
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
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
$ 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
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
$ 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)
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.)
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.
Merged fix into [e232836cee].