Tcl Source Code

View Ticket
Login
Ticket UUID: 962519
Title: nativeFilesystemRecord comparisions invalid with threads
Type: Bug Created on: 2004-05-28 23:47:02
Submitter: dgp Assigned to: vasiljevic
Subsystem: 37. File System Severity:
Priority: 5 Medium Last modified: 2026-10-22 17:19:32
Status: Closed Closed by: serhiy.storchaka
Resolution: Fixed Closed on: 2026-10-21 10:03:39
Version: obsolete: 8.5a2
Description:
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.
User Comments:
vasiljevic added on 2004-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

dgp added on 2004-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.

dgp added on 2004-06-10 20:55:07:
Logged In: YES 
user_id=80530

handing this back to you too.

dgp added on 2004-07-06 22:12:37:
Logged In: YES 
user_id=80530


I lost track.  Did this get fixed?

vasiljevic added on 2004-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.

dgp added on 2005-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?

vasiljevic added on 2005-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.

dgp added on 2007-09-05 23:13:15:
Logged In: YES 
user_id=80530
Originator: YES

status?

serhiy.storchaka added on 2026-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.