|
2010-01-06
| ||
| 02:00 | • Closed ticket [2918610fff]: Wrong file opened plus 7 other changes artifact: 75dcdffb4c user: dgp | |
| 01:51 | • Ticket [2918610fff]: 4 changes artifact: e0d5e27de6 user: dgp | |
| 01:51 | • Add attachment 2918610.patch to ticket [2918610fff] artifact: 10d65cf507 user: dgp | |
| 01:13 | • Ticket [2918610fff] Wrong file opened status still Open with 4 other changes artifact: e342c7d352 user: dgp | |
|
2009-12-23
| ||
| 04:55 | • Ticket [2918610fff]: 4 changes artifact: c3261f3b34 user: dgp | |
| 04:54 | • Ticket [2918610fff]: 4 changes artifact: 03d97e608e user: dgp | |
| 03:56 | • Ticket [2918610fff]: 4 changes artifact: 3de013adde user: dgp | |
| 03:32 | • Ticket [2918610fff]: 4 changes artifact: 3a5ccc5d7d user: dgp | |
| 01:02 | • Ticket [2918610fff]: 4 changes artifact: f18420bb7f user: magv | |
|
2009-12-22
| ||
| 23:35 | • Ticket [2918610fff]: 4 changes artifact: 9bae849ce1 user: dkf | |
| 17:52 | • Ticket [2918610fff]: 4 changes artifact: 6932d51f46 user: ferrieux | |
| 17:52 | • Ticket [2918610fff]: 4 changes artifact: 17730417b3 user: ferrieux | |
| 17:47 | • Ticket [2918610fff]: 4 changes artifact: 4d084ea771 user: ferrieux | |
| 17:47 | • Add attachment rootname.patch to ticket [2918610fff] artifact: 8c56d76e71 user: ferrieux | |
| 17:15 | • Ticket [2918610fff] Wrong file opened status still Open with 4 other changes artifact: e47b100f9e user: ferrieux | |
| 17:05 | • Ticket [2918610fff]: 4 changes artifact: 8952a87704 user: ferrieux | |
| 04:52 | • Ticket [2918610fff]: 4 changes artifact: 344ca18c8f user: ferrieux | |
| 02:13 | • Ticket [2918610fff]: 4 changes artifact: a04cca5b5e user: dkf | |
| 00:12 | • Ticket [2918610fff]: 4 changes artifact: 5190b90a43 user: ferrieux | |
|
2009-12-21
| ||
| 22:13 | • Ticket [2918610fff]: 3 changes artifact: 4db2d047b5 user: dkf | |
| 21:36 | • Ticket [2918610fff]: 4 changes artifact: c66c4acb46 user: cc_benny | |
| 11:28 | • New ticket [2918610fff]. artifact: d0927f230d user: magv | |
Wrong file opened
Closed / Fixed2918610fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2009-12-21 11:28:03
Here's a stripped down code snippet:
set root somedir
exec rm -rf $root
exec mkdir -p $root
exec touch $root/x.y
file normalize anything
foreach fn [glob $root/x.y] {
set ofn [file rootname $fn]
set fl [open $ofn {WRONLY CREAT}]
puts $fl "something"
close $fl
}
puts [exec ls $root]
I expect this code to put "something" into somedir/x, and then print x and x.y. Instead it puts "something" into somedir/x.y, and prints x.y; somedir/x is not created, even though $ofn is somedir/x.
I tried this code in the following environments:
* FreeBSD/i386 7-STABLE, Tcl 8.4.19 -- works as expected
* FreeBSD/i386 7-STABLE, Tcl 8.5.8 -- fails as described
* FreeBSD/i386 7-STABLE, Tcl 8.6-b1 -- fails as described
* FreeBSD/amd64 8.0-RC2, Tcl 8.5.8 -- fails as described
* Windows XP, ActiveTcl 8.5.8 -- works as expected
Alexandre Ferrieux was kind enough to test in another environment [1]:
* Windows/MinGW, Tcl 8.5-HEAD -- works as expected
Note that removing the void [file normalize], replacing glob with it's value, or removing foreach loop also makes it work as expected.
I will try to run the code on other systems to see if it's specific to FreeBSD (maybe FreeBSD port patches are to blame).
[1] http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/859e950831fa3e9b
cc_bennyplain2009-12-21 21:36:37
I can confirm the behaviour with these: Mac OS X 10.4.11, Tcl 8.4.7 -- works Mac OS X 10.4.11, Tcl 8.5.7 (MacPorts) -- fails Mac OS X 10.4.11, Tcl 8.5.8 (CVS current) -- fails Mac OS X 10.4.11, Tcl 8.6b1.1 (CVS current) -- fails Linux Ubuntu 9.10 (PPC), Tcl 8.4.19 -- works Linux Ubuntu 9.10 (PPC), Tcl 8.5.8 (Source) -- fails Linux Ubuntu 9.10 (PPC), Tcl 8.6b1.1 (CVS current) -- fails Looks to me like the breakage is in the Unix code, introduced somewhere in the early 8.5 versions.
dkf Ticket [2918610fff]: 3 changes
[History diff]2009-12-21 22:13:22
ferrieuxplain2009-12-22 00:12:41
I am an absolute ignorant of these things, but single-stepping shows that in the TclPathPart routine, case TCL_PATH_ROOT, when the result object is created, it is built by half-hearted duplication: the PATHOBJ itself is properly duplicated, but its fields are only lazily separated from the original. Indeed: normPathPtr is actively split off, because it holds the prime result; similarly the string rep is proprely separated (by T_DupObj) and updated. However, the other fields of the fsDupPtr are left untouched, and they are shared with the original path (argument of [file rootname]): translatedPathPtr and nativePathPtr. I assume that these should be simply invalidated, though I don't know how (not much time to dive now).
dkfplain2009-12-22 02:13:07
Just noting that there have been persistent nagging bugs in this area, so something is definitely wrong and nobody's fixed it yet. (Also noting that I've never seriously poked my nose into this area, and don't propose to start now.)
ferrieuxplain2009-12-22 04:52:03
Not much progress to report.. except that the dichotomy between the failing and non-failing cases is due to the following test in TclPathPart:
if (TclFSEpochOk(fsPathPtr->filesystemEpoch)
&& (PATHFLAGS(pathPtr) != 0)) {
with the dangerous field-sharing branch exposed when the "if" succeeds.
I have yet to grok why this happens only on unix. TBC.
ferrieuxplain2009-12-22 17:05:01
Continuimg at a snail's pace... the offending flag is TCLPATH_APPENDED. This flags is set by default when creating a path object with TclNewFSPathObj, so the question becomes, Why on Windows (and on earth) is it reset afterwards ?
ferrieuxplain2009-12-22 17:15:47
Also, it looks like another facet of what happened in 2710920: a brittle PATHFLAGS!=0 code branch.
ferrieuxplain2009-12-22 17:47:29
File Added - 356110: rootname.patch
ferrieuxplain2009-12-22 17:52:18
Rather than chasing the whereabouts of the various flags (which have a right to exist anyway), I prefer to fix the broken code. Attached patch does this by invalidating both the translated and native paths after the duplication. I am uneasy about the freeing of the native path though. Currently it is freed only if the fsRecPtr *and* associated freeIntRepProc are not-null, but in any case the nativepathPtr is reset to NULL. So there's a potential leak if either of the above fs-related pointers is null. But I didn't find any example of freeing code doing more. Is it correct ?
ferrieuxplain2009-12-22 17:52:47
Of course it fixes the local bug and passes the test suite...
dkfplain2009-12-22 23:35:12
It passes the test suite? That's good. The other thing to check is what impact it has on Tcl's startup time with a large auto_path or auto_path of large directories, notably including /usr/lib which is why there's been a problem in the past. (Trying to remember why we've got all this complex infrastructure here in the first place... :-)) Before commit, the issue identified must be clearly tested for in a self-contained test and you need to check that the test fails before application of the patch and succeeds afterwards. I say this because failing to do that sort of thing has got me in trouble in the past, and VFS path objects are (clearly) very tricky.
magvplain2009-12-23 01:02:50
Thanks, Alexandre. Your patch does wonders (even if it may not be a permanent solution).
dgpplain2009-12-23 03:32:30
Bug introduced between 8.5.2 and 8.5.3
dgpplain2009-12-23 03:56:24
Likely more fallout from the 1972879 fix.
dgpplain2009-12-23 04:54:19
This appears to be an exposure of an existing bug, rather than a new one. Appears the PATHFLAGS != 0 and portion == TCL_PATH_ROOT branch has always been wrong wrong wrong yet somehow that combination never happened until the changes for 8.5.3. Alex's patch is one sensible way to fix the brokenness. I want to chase down a slightly different fix before commit.
dgpplain2009-12-23 04:55:39
I also have a testing script I am using to probe this, which I will convert to a test before commit (dkf is right!)
dgpplain2010-01-06 01:13:53
The pattern for this bug almost perfectly matches 2710920.
dgpplain2010-01-06 01:51:09
File Added - 357792: 2918610.patch
dgpplain2010-01-06 02:00:08
allow_comments - 1 Attached patch committed for 8.5.9 and 8.6b2.
Log in (anonymous is fine) to add a comment.
Attachments:
- 2918610.patch [download] added by dgp on 2010-01-06 01:51:09. [details]
- rootname.patch [download] added by ferrieux on 2009-12-22 17:47:29. [details]