Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-22
17:19 • Ticket [962519ffff] nativeFilesystemRecord comparisions invalid with threads... artifact: c91556ccd2 user: serhiy.storchaka
2026-10-21
10:03 • Closed ticket [962519ffff]. artifact: 3fd74d9960 user: serhiy.storchaka
2007-09-05
23:13 • Ticket [962519ffff]: 4 changes artifact: 24e0a41610 user: dgp
2005-07-06
00:07 • Ticket [962519ffff]: 4 changes artifact: 1a05d077a9 user: vasiljevic
2005-07-05
23:58 • Ticket [962519ffff]: 4 changes artifact: f42d046fe2 user: dgp
2004-07-06
22:48 • Ticket [962519ffff]: 4 changes artifact: 25da021f44 user: vasiljevic
22:12 • Ticket [962519ffff]: 4 changes artifact: 2173d35e57 user: dgp
2004-06-10
20:55 • Ticket [962519ffff]: 5 changes artifact: a441918a99 user: dgp
2004-06-09
21:26 • Ticket [962519ffff]: 5 changes artifact: cea36859e3 user: dgp
20:55 • Ticket [962519ffff]: 4 changes artifact: ffcdcb8152 user: vasiljevic
20:55 • Ticket [962519ffff]: 1 change artifact: 4a4b8f690a user: vasiljevic
2004-05-28
23:47 • New ticket [962519ffff]. artifact: 0b843c9cb4 user: dgp

nativeFilesystemRecord comparisions invalid with threads

Closed / Fixed962519ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 41 days ago
Descriptionplain2004-05-28 23:47:02
Two routines in tclIOUtil.c,
FsListMounts() and
TclFSNormalizeToUniquePath()
do direct comparisons to the
value &nativeFilesystemRecord.

However, in a --enable-threads
build of Tcl, those routines do not
loop over a list containing that
static record.  Instead they loop
over a thread-specific copy of
the original list.  Thus, these
comparisions are either always
true or always false when
threads are enabled, destroying
the logic intended.

This bug will be automatically
fixed if we stop using thread-specific
copies of the filesystem records.
That's also the best way to fix
Bug 932314.

Will develop a patch and submit
when it is ready.
vasiljevic Ticket [962519ffff]: 1 change [History diff]2004-06-09 20:55:22
vasiljevicplain2004-06-09 20:55:23
Logged In: YES 
user_id=95086

Hi Don!

I'm the one to blame :) Sorry for not answering before
but I was simply not able to.

I will reassign this bug to myself instead of Vince.

To be honest I do not really understand the point.
The introduction of the per-thread private list was
to get Tcl FS behave properly in therad-builds
a) with mimumum possible lock contention
b) w/o danger of passing Tcl_Objs between therads
c) w/o excessive Tcl_Obj copying

The code is there since 8.4 and I made it since 
we experienced strange memory corruption when
operating in threaded env (AOLserver project). 
Since that change, all was fine so I'm little worried
about abandoning the private per-thread list of 
ergistered filesystems and per-therad copy of the
current working dir.

Now, I think you've seen that the static global
list of registered filesystems is epoch-stamped
and always checked against the private per-thread
copy. This way it is assured that the private copy
does not reflect stale data. 

In case I'm missing some important part, I would
be happy if you could elaborate little bit more on this
topic so I can see what problems you're reffering to.

Cheers,
Zoran
dgpplain2004-06-09 21:26:58
Logged In: YES 
user_id=80530

Hi Zoran.

Trouble is that the epoch checks
are not working properly.  See
Tcl Bug 932314 for a report on
that problem.  The fact that this
bug will also be corrected by
a new approach is just an
additional benefit.

What I want to do is have all
threads access a single copy
of the filesystemList.  I agree
that doing that with MutexLock
protection leads to unacceptable
lock contention.  So, I would
migrate to concurrent-read,
exclusive write locks on the
resource.

Access to filesystemList is
read-mostly.  Only FS registration
and mounting cause writes,
and they are much rarer than
consulting the list to resolve
paths.  As long as the reads do
not contend with one another
for access, there should be little
noticeable problem.

I already have CREW locks in
an implementation of my own
filesystem, so I know they work,
and it should not be too hard for
me to work up a core patch. 
Sorry, I haven't done it yet.
Been distracted by a few other things.
dgpplain2004-06-10 20:55:07
Logged In: YES 
user_id=80530

handing this back to you too.
dgpplain2004-07-06 22:12:37
Logged In: YES 
user_id=80530


I lost track.  Did this get fixed?
vasiljevicplain2004-07-06 22:48:09
Logged In: YES 
user_id=95086

It did AFAIK. 
This one is still open as a reminder if we get 
any problems in this area in the future.
dgpplain2005-07-05 23:58:11
Logged In: YES 
user_id=80530


been open a year now.

do you still need a reminder
about future problems, or
is this ready for closing now?
vasiljevicplain2005-07-06 00:07:10
Logged In: YES 
user_id=95086

Oh, please leave it open. I will very soon start to 
hit this part with some stress testing since we 
are about to adopt the TclVFS in our product.
If I still feel comfortable after that, I'll close this one.
dgpplain2007-09-05 23:13:15
Logged In: YES 
user_id=80530
Originator: YES

status?
serhiy.storchakawiki2026-10-21 10:03:39

Fixed in 8.4.13/8.5.0 by [b8ef0f05a3] ([bfa4344c2c] on 8.4): the loops over the thread-local filesystem list compare fsPtr with &tclNativeFilesystem instead of the static record. No problems were reported in this area since then, so closing.

serhiy.storchaka Ticket [962519ffff]: 3 changes [History diff]2026-10-22 17:19:32
Log in (anonymous is fine) to add a comment.