|
2026-11-23
| ||
| 23:13 | • Closed ticket [4d3f213029]: VFS support causes infinite recursion during 'fi... artifact: 49b32db7f6 user: jan.nijtmans | |
| 13:32 | • Ticket [4d3f213029]: 3 changes artifact: 1b6add3f04 user: serhiy.storchaka | |
| 13:31 | Fix [4d3f213029] on 8.6: backport [82a62c58b9] (fix for [e2698b94b1]). When getcwd() fails, Tcl_FSGe... closed check-in: e590554a8f user: serhiy.storchaka tags: getcwd-failure-8-6 | |
| 12:05 | • Ticket [4d3f213029] VFS support causes infinite recursion during 'file exist... artifact: 2ddd3893ee user: jan.nijtmans | |
| 12:05 | Mark source-9.1 and 9.2 as knownBug. See: [4d3f213029] check-in: d226ac1f9c user: jan.nijtmans tags: core-8-6-branch | |
| 11:18 | • Ticket [4d3f213029] VFS support causes infinite recursion during 'file exist... artifact: 218733cacb user: jan.nijtmans | |
| 11:13 | • Pending ticket [4d3f213029]. artifact: 2e96d01314 user: jan.nijtmans | |
|
2026-11-16
| ||
| 10:43 | • Closed ticket [4d3f213029]. artifact: 14ce21c8af user: oehhar | |
| 10:41 | [4d3f2130292dbfe3] infinite recursion during 'file exists' if working directory has been removed check-in: 57b7358a87 user: oehhar tags: core-8-6-branch | |
| 09:41 | [4d3f2130292dbfe3] infinite recursion during 'file exists' if working directory has been removed check-in: 3dce174010 user: oehhar tags: core-9-0-branch | |
| 09:40 | [4d3f2130292dbfe3] infinite recursion during 'file exists' if working directory has been removed check-in: ca784f17f6 user: oehhar tags: trunk, main | |
|
2026-11-15
| ||
| 17:01 | • Ticket [4d3f213029] VFS support causes infinite recursion during 'file exist... artifact: 3f3b637d7f user: oehhar | |
|
2026-11-14
| ||
| 17:13 | • Ticket [4d3f213029]: 4 changes artifact: 247d8450c9 user: oehhar | |
|
2026-11-12
| ||
| 08:50 | • Ticket [4d3f213029]: 4 changes artifact: 10f979df60 user: oehhar | |
| 08:44 | [4d3f213029] merge main closed check-in: 7cd59ab35f user: oehhar tags: eval-cwd-deleted | |
|
2026-10-22
| ||
| 20:31 | Fix [4d3f213029] for the case where [pwd] already failed after the current directory was deleted: Tc... check-in: e2e5c2656c user: serhiy.storchaka tags: eval-cwd-deleted | |
|
2026-10-13
| ||
| 20:09 | • Ticket [4d3f213029] VFS support causes infinite recursion during 'file exist... artifact: 104a0eeb21 user: serhiy.storchaka | |
| 20:08 | Fix [4d3f213029]: evaluating a script sourced with a relative path after its current directory was d... check-in: 58b479ca8a user: serhiy.storchaka tags: eval-cwd-deleted | |
|
2023-04-25
| ||
| 15:21 | • Ticket [4d3f213029] VFS support causes infinite recursion during 'file exist... artifact: c667ecbe65 user: jrioux | |
| 14:33 | • Ticket [4d3f213029]: 4 changes artifact: 5d4ec96fe8 user: oehhar | |
| 14:17 | • New ticket [4d3f213029]. artifact: 85e7c0bfd6 user: jrioux | |
VFS support causes infinite recursion during 'file exists' if working directory has been removed
Tested on Ubuntu 22.04 with Tcl 8.6.12 and VFS 1.4.2 The following minimal example causes tclsh to segfault (infinite recursion). Expected was that no segmentation fault occurs. package require vfs set testdir directory_for_testing_will_be_deleted set testdir_abs [file join [pwd] $testdir] file mkdir $testdir cd $testdir puts "Current working dir: [pwd]" file delete $testdir_abs puts "Current working dir: [pwd]" puts "File exists: [file exists .]"
e590554a8fFix [4d3f213029] on 8.6: backport [82a62c58b9] (fix for [e2698b94b1]). When getcwd() fails, Tcl_FSGetCwd() returned an empty path instead of NULL, so [pwd] returned "" without an error. source-9.1 and 9.2 pass again. check-in2026-11-23 13:31:37d226ac1f9cMark source-9.1 and 9.2 as knownBug. See: [4d3f213029] check-in2026-11-23 12:05:297cd59ab35f[4d3f213029] merge main check-in2026-11-12 08:44:12e2e5c2656cFix [4d3f213029] for the case where [pwd] already failed after the current directory was deleted: TclFSCwdPointerEquals() compared the path with the NULL cached cwd and crashed. Return 0 then. Test source-9.2. check-in2026-10-22 20:31:0058b479ca8aFix [4d3f213029]: evaluating a script sourced with a relative path after its current directory was deleted corrupted memory: TclEvalEx() jumped to its error handler before parsing a command when the path could not be normalized. Use the path as is; it is only used for location information. check-in2026-10-13 20:08:00
Julien,
thanks for the bug report. Why is this related to vfs? The issue only happens with the package require vfs? But you only work on real files, do you?
On TCL8.6.13 32bit on Windows 10 64 bit, the example does not work, as one may not delete the working directory. By adding "-force" to delete, it works. But the pwd is adjusted, to point to a present folder.
Here is an interactive session:
% set testdir directory_for_testing_will_be_deleted directory_for_testing_will_be_deleted % set testdir_abs [file join [pwd] $testdir] C:/myprograms/tcl8.6/bin/directory_for_testing_will_be_deleted % file mkdir $testdir % cd $testdir % pwd C:/myprograms/tcl8.6/bin/directory_for_testing_will_be_deleted % file delete -force $testdir_abs % pwd C:/myprograms/tcl8.6/bin % file exists . 1
Maybe, you also post the output of your program.
Take care, Harald
Yes the bug is only reproducible with "package require vfs" and most likely only on linux. Here the program output running in gdb: (gdb) r Starting program: /usr/bin/tclsh warning: Error disabling address space randomization: Operation not permitted [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". % package require vfs 1.4.2 % set testdir directory_for_testing_will_be_deleted directory_for_testing_will_be_deleted % set testdir_abs [file join [pwd] $testdir] /directory_for_testing_will_be_deleted % file mkdir $testdir % cd $testdir % puts "Current working dir: [pwd]" Current working dir: /directory_for_testing_will_be_deleted % file delete $testdir_abs % puts "Current working dir: [pwd]" Current working dir: % puts "File exists: [file exists .]" Program received signal SIGSEGV, Segmentation fault. 0x00007fb74877effd in Tcl_FSGetCwd () from /lib/x86_64-linux-gnu/libtcl8.6.so (gdb) bt #0 0x00007fb74877effd in Tcl_FSGetCwd () from /lib/x86_64-linux-gnu/libtcl8.6.so #1 0x00007fb748796099 in Tcl_FSGetNormalizedPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #2 0x00007fb748002c36 in ?? () from /usr/lib/tcltk/x86_64-linux-gnu/vfs1.4.2/libvfs1.4.2.so #3 0x00007fb748780b9e in Tcl_FSGetFileSystemForPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #4 0x00007fb74877f1c9 in Tcl_FSGetCwd () from /lib/x86_64-linux-gnu/libtcl8.6.so #5 0x00007fb748796099 in Tcl_FSGetNormalizedPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #6 0x00007fb748002c36 in ?? () from /usr/lib/tcltk/x86_64-linux-gnu/vfs1.4.2/libvfs1.4.2.so #7 0x00007fb748780b9e in Tcl_FSGetFileSystemForPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #8 0x00007fb74877f1c9 in Tcl_FSGetCwd () from /lib/x86_64-linux-gnu/libtcl8.6.so #9 0x00007fb748796099 in Tcl_FSGetNormalizedPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #10 0x00007fb748002c36 in ?? () from /usr/lib/tcltk/x86_64-linux-gnu/vfs1.4.2/libvfs1.4.2.so #11 0x00007fb748780b9e in Tcl_FSGetFileSystemForPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #12 0x00007fb74877f1c9 in Tcl_FSGetCwd () from /lib/x86_64-linux-gnu/libtcl8.6.so #13 0x00007fb748796099 in Tcl_FSGetNormalizedPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #14 0x00007fb748002c36 in ?? () from /usr/lib/tcltk/x86_64-linux-gnu/vfs1.4.2/libvfs1.4.2.so #15 0x00007fb748780b9e in Tcl_FSGetFileSystemForPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #16 0x00007fb74877f1c9 in Tcl_FSGetCwd () from /lib/x86_64-linux-gnu/libtcl8.6.so #17 0x00007fb748796099 in Tcl_FSGetNormalizedPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #18 0x00007fb748002c36 in ?? () from /usr/lib/tcltk/x86_64-linux-gnu/vfs1.4.2/libvfs1.4.2.so #19 0x00007fb748780b9e in Tcl_FSGetFileSystemForPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #20 0x00007fb74877f1c9 in Tcl_FSGetCwd () from /lib/x86_64-linux-gnu/libtcl8.6.so #21 0x00007fb748796099 in Tcl_FSGetNormalizedPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #22 0x00007fb748002c36 in ?? () from /usr/lib/tcltk/x86_64-linux-gnu/vfs1.4.2/libvfs1.4.2.so #23 0x00007fb748780b9e in Tcl_FSGetFileSystemForPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #24 0x00007fb74877f1c9 in Tcl_FSGetCwd () from /lib/x86_64-linux-gnu/libtcl8.6.so #25 0x00007fb748796099 in Tcl_FSGetNormalizedPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #26 0x00007fb748002c36 in ?? () from /usr/lib/tcltk/x86_64-linux-gnu/vfs1.4.2/libvfs1.4.2.so #27 0x00007fb748780b9e in Tcl_FSGetFileSystemForPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #28 0x00007fb74877f1c9 in Tcl_FSGetCwd () from /lib/x86_64-linux-gnu/libtcl8.6.so #29 0x00007fb748796099 in Tcl_FSGetNormalizedPath () from /lib/x86_64-linux-gnu/libtcl8.6.so #30 0x00007fb748002c36 in ?? () from /usr/lib/tcltk/x86_64-linux-gnu/vfs1.4.2/libvfs1.4.2.so #31 0x00007fb748780b9e in Tcl_FSGetFileSystemForPath () from /lib/x86_64-linux-gnu/libtcl8.6.so --Type <RET> for more, q to quit, c to continue without paging-- The ?? in the stack trace should be VfsPathInFilesystem if I am not mistaken.
Not specific to VFS: in 9.0 and 9.1, where zipfs is always registered, the
example crashes without any extension. When a script sourced with a relative
path is evaluated after its current directory was deleted, its path cannot be
normalized, and TclEvalEx() then jumped to its error handler
before parsing a command, using uninitialized data and corrupting memory.
Proposed fix in branch eval-cwd-deleted: use
the path as is, it is only used for location information. The script then
gets the usual errors for pwd and glob. Test
source-9.1.
Fix effective on Windows. Will merge after CI due to "perhaps Linux only" given in the description.
Thanks for all, Harald
Jan, you have removed the "core-eval-cwd-deleted". I did not find the CI run. Is it me? I have reset this tag.
Sorry, Harald
CI fully clean. Will merge tomorrow.
Thanks for all, Harald
Merged to:
- main [ca784f17]
- core-9-0-branch [3dce1740]
- core-8-6-branch [57b7358a]
Bug closed.
Thanks for all, Harald
In core-8-6-branch:
==== source-9.1 source with relative path after the current directory was deleted FAILED
==== Contents of test case:
exec sh -c {cd "$1" && exec "$2" cwddeleted.tcl} sh $dir [interpreter]
---- Result was:
0 0 1
---- Result should have been (exact matching):
1 0 0
==== source-9.1 FAILED
==== source-9.2 source with relative path after the current directory was deleted and [pwd] failed FAILED
==== Contents of test case:
exec sh -c {cd "$1" && exec "$2" cwddeleted.tcl} sh $dir [interpreter]
---- Result was:
0 0 1
---- Result should have been (exact matching):
1 0 0
==== source-9.2 FAILED]
Bisecting shows:
$ fossil bisect chart 1 BAD 2026-11-23 10:36:57 d762377fa4ac44aa 5 BAD 2026-11-18 18:22:08 69c0fdc481139395 6 BAD 2026-11-16 12:56:57 e0480cc1b4b52da3 8 BAD 2026-11-16 10:41:26 57b7358a875cc03d CURRENT 7 GOOD 2026-11-15 14:13:37 b74cee085c1a5620 4 GOOD 2026-11-11 13:50:19 41c90339a6ece4d8 3 GOOD 2026-10-28 11:09:51 f53502fa2a30da96 2 GOOD 2026-10-01 22:44:48 342ab733c3d5998b
This points to exactly the commit where this fix was merged to core-8-6-branch (while core-9-0-branch and trunk appear to be OK). Somehow this solution doesn't work on 8.6.
I'm having a look at it, but if someone else has an idea why this doesn't work on 8.6, but works fine with 9.x, please come forward!
Since the patch doesn't appear to have any negative side-effect, I marked the source-9.1 and 9.2 testcases as 'knownBug' for now.
I suspect that some additional bug-fix, already done in 9.0, needs a backport for those 2 testcases to work .....
The missing fix is [82a62c58b9] for [e2698b94b1] (Tcl_FSChdir crashes after seteuid), which is only in 9.0 and main. In 8.6, when getcwd() fails, Tcl_FSGetCwd() sets the error message but continues, and turns the NULL into an empty path, so pwd returns "" and file exists . returns 1. Backport in branch getcwd-failure-8-6 (by hand, the comments differ), with the knownBug marks removed: source-9.1 and 9.2 pass, and so does the whole test suite.
Thanks, that was it! Everything OK now!