| Ticket UUID: | 4d3f2130292dbfe33977659c2afe98c7bb86b668 | ||
| Title: | VFS support causes infinite recursion during 'file exists' if working directory has been removed | ||
| Type: | Bug | Created on: | 2023-04-25 14:17:21 |
| Submitter: | jrioux | Assigned to: | nobody |
| Subsystem: | 37. File System | Severity: | Important |
| Priority: | 5 Medium | Last modified: | 2026-11-16 10:43:04 |
| Status: | Closed | Closed by: | oehhar |
| Resolution: | Fixed | Closed on: | 2026-11-16 10:43:04 |
| Version: | 9.0.5, 9.1.0 | ||
| Description: | ||||
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 .]" | ||||
| User Comments: | ||||
oehhar added on 2023-04-25 14:33:54:
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 jrioux added on 2023-04-25 15:21:52:
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. serhiy.storchaka added on 2026-10-13 20:09:22:
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 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 oehhar added on 2026-11-12 08:50:53:
Fix effective on Windows. Will merge after CI due to "perhaps Linux only" given in the description. Thanks for all, Harald oehhar added on 2026-11-14 17:13:27:
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 oehhar added on 2026-11-15 17:01:42:
CI fully clean. Will merge tomorrow. Thanks for all, Harald oehhar added on 2026-11-16 10:43:04:
Merged to:
Bug closed. Thanks for all, Harald | ||||
