Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2013-09-24
12:06 • Closed ticket [3024359fff]: Crash in Tcl_FSGetFileSystemForPath plus 6 other... artifact: 64addd7042 user: dkf
2012-06-25
23:44 • Pending ticket [3024359fff]. artifact: 2765347397 user: dgp
22:21 • Ticket [3024359fff]: 4 changes artifact: 2140f855c0 user: dgp
2012-06-22
23:45 • Ticket [3024359fff]: 4 changes artifact: af2798ac81 user: dgp
02:12 • Ticket [3024359fff]: 4 changes artifact: 6e940f7efb user: dgp
02:00 • Ticket [3024359fff]: 4 changes artifact: e6db190612 user: dgp
01:54 • Ticket [3024359fff]: 4 changes artifact: 540fd315e0 user: dgp
2012-06-19
03:37 • Ticket [3024359fff]: 4 changes artifact: d0be19992e user: dgp
02:40 • Ticket [3024359fff]: 4 changes artifact: 04cde35e28 user: dgp
2012-06-12
20:46 • Ticket [3024359fff]: 4 changes artifact: eecba31685 user: dgp
05:26 • Ticket [3024359fff]: 4 changes artifact: 103d07e62f user: dgp
05:23 • Open ticket [3024359fff]. artifact: 749b32b9b0 user: dgp
2012-06-11
23:41 • Pending ticket [3024359fff]. artifact: 7bf29eded7 user: dgp
2012-05-29
20:40 • Ticket [3024359fff]: 1 change artifact: 3923f78c5d user: dgp
20:40 • Ticket [3024359fff]: 4 changes artifact: 62c2518733 user: dgp
16:12 • Ticket [3024359fff]: 1 change artifact: 10b1e04a77 user: dkf
2010-07-02
13:02 • New ticket [3024359fff]. artifact: a503fce0e6 user: neilhampton

Crash in Tcl_FSGetFileSystemForPath

Closed / Fixed3024359fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 13 years ago
Descriptionplain2010-07-02 13:02:16
We have a multi-threaded tclkit application that runs several scripts on different threads and it crashes in Tcl_FSGetFileSystemForPath on the line "fsRecPtr = fsRecPtr->nextPtr".

From investigation, it appears that 'theFilesystemEpoch' is being updated within the loop and the threads file system list is being re-cached leaving fsRecPtr pointing at freed memory.  It is very difficult to track, but it appears that Tcl_FSMountsChanged is being called from within Tcl_FSGetFileSystemForPath.  The path being accessed is the 'wrapped' init.tcl.
dkf Ticket [3024359fff]: 1 change [History diff]2012-05-29 16:12:57
dgpplain2012-05-29 20:40:43
This is reported against 8.5.8.  Has it been reconfirmed
with either 8.5.11 release, or current state of core-8-5-branch?
dgp Ticket [3024359fff]: 1 change [History diff]2012-05-29 20:40:44
dgpplain2012-06-11 23:41:49
The issue appears to be care needed by callers of
FsGetFirstFilesystem().  Any caller that keeps and
makes use of the value it returns needs to take care
not to continue using that value whenever another
call to FsGetFirstFilesystem() might be made in the
same thread.  Since TclFSEnsureEpochOk() does
just that, it's clear that Tcl_FsGetFileSystemForPath()
has the potential for this kind of trouble.  The need to
make both those calls and make sure they both report
results on the same epoch is a bit of a puzzle.
dgp Open ticket [3024359fff]. [History diff]2012-06-12 05:23:28
dgpplain2012-06-12 05:26:40
First draft fix committed to branch bug-3024359.  Needs tests and testing.
dgpplain2012-06-12 20:46:17
Second draft committed, but it's now clear these patches
are broken.  Although they preserve the FilesystemRecord
linked lists while they are in use, avoiding the reported crashes,
the result is that when a search of these preserved records
succeeds, the incorrect epoch value is recorded, so that a
record retrieved from an outdated epoch is stored as if it
were current.
dgpplain2012-06-19 02:40:22
This seems to be a controlled way to test
for the bug.  Doesn't easily convert to a test
for the test suite.

package require Thread
thread::create {while 1 {set env(HOME) /home/user[incr i]}}
while 1 {file system foo}
dgpplain2012-06-19 03:37:17
Next draft fix committed.  This one appears to solve
the problem, at least as far as that test demonstrates.
dgpplain2012-06-22 01:54:57
Some simplifications of the internals of fs path values
just committed to the 8.5 and trunk branches has the
effect of also making the posted test pass.

I have my doubts these changes are a complete fix for
the issue of managing the mount epoch properly (still
pursuing that on the bug-3024359 branch) but they may
be sufficient to repair the problems observed by the
original poster.
dgpplain2012-06-22 02:00:16
Aha!  Strike that last comment.  Still seeing
crashes on 8.5 branch.  Developing fix is
still on the bug-3024359 branch.
dgpplain2012-06-22 02:12:22
The crashing is much less frequent though, which
suggests that the FsGetFirstFilesystem() call in the
(now deleted) helper routine TclFsInternalToNormalized()
was the one most frequently causing a bump in the
per-thread filesystemEpoch value at a time that could cause
trouble.
dgpplain2012-06-22 23:45:28
Revised the code to restore the crashing.  The bug is still
present on 8-5-branch, but was able to hide by getting lucky
with memory allocation patterns.  Now it cannot hide.  Bugs
that don't hide are easier to fix.
dgpplain2012-06-25 22:21:19
Fix committed to core-8-5-branch for release in 8.5.12.

Confirmation that it fixes the reported bug would be welcome.
dgpplain2012-06-25 23:44:18
Fix merged to trunk as well.
dkf Closed ticket [3024359fff]. [History diff]2013-09-24 12:06:32
Log in (anonymous is fine) to add a comment.