Tcl Source Code

View Ticket
Login
Ticket UUID: 2837204
Title: glob on realtive patterns and dirs is thread "unsafe"
Type: Bug Created on: 2009-08-13 22:39:32
Submitter: dgp Assigned to: dgp
Subsystem: 37. File System Severity:
Priority: 3 Low Last modified: 2009-08-14 09:07:18
Status: Open Closed by:
Resolution: None Closed on:
Version: None
Description:
[glob] gets implemented recursively and depending
on the switches and patterns can result in a whole
tree of calls to Tcl_FSMatchInDirectory().  If the
directories are named by relative paths, then they
are taken relative to the cwd - which is a process wide
value that can be changed at arbitrary times by
other threads in the process.  This means that
some portions of the [glob] search might take
place with different [pwd] values than other portions,
and the assembled list of [glob] results does not
actually represent any properly functioning,
consistent filesystem search.

In concept, the fix would be to determine [pwd]
once at the beginning of the glob operation and
then take care to pass it down the whole tree
of operations for consistent results rooted on
/some/ consistent value of [pwd].

Low priority, I think, but wanted to record the
issue while I noticed it.
User Comments:
das added on 2009-08-14 09:07:18:
Not directly related, but FWIW I remember a similar issue with [file normalize] and threading on early versions of Darwin where the realpath() implementation was changing the cwd internally... (messing up all relative path processing in all other threads).