Overview
| Artifact ID: | 97f37b94589afb3f3cc5dd3d68afa7ed6a08aa04 |
|---|---|
| Ticket: | 1064247fffffffffffffffffffffffffffffffff
filesystem-7.8 fails on darwin without NO_REALPATH |
| User & Date: | das on 2006-03-28 15:47:35 |
Changes
- foundin changed to: "obsolete: 8.5a3"
- icomment:
Logged In: YES user_id=90580 Vince, this is still failing, looking it why once again you wrote: > TclpObjNormalizePath should not be called on a path starting > with "simplefs:/" (assuming the simplefilesystem is > registered, of course). > > Why is this being called? the relevant backtrace from current HEAD is (gdb) bt #0 TclpObjNormalizePath (interp=0x0, pathPtr=0x7a6018, nextCheckpoint=0) at unix/tclUnixFCmd.c:1870 #1 0x000a6854 in TclFSNormalizeToUniquePath (interp=0x0, pathPtr=0x7a6018, startAt=0, clientDataPtr=0xbfff9ae0) at generic/ tclIOUtil.c:1448 #2 0x000cb6cc in TclFSNormalizeAbsolutePath (interp=0x0, pathPtr=0x7a6450, clientDataPtr=0xbfff9b98) at generic/tclPathObj.c:406 #3 0x000ce5cc in Tcl_FSGetNormalizedPath (interp=0x0, pathPtr=0x7a64c8) at generic/tclPathObj.c:1900 #4 0x000a8c30 in Tcl_FSChdir (pathPtr=0x7a64c8) at generic/ tclIOUtil.c:2854 i.e. Tcl_FSGetNormalizedPath calls TclFSNormalizeAbsolutePath with a pathPtr of 'simplefs:/simpledir' which in turn calls TclFSNormalizeToUniquePath with the same pathPtr, which ends up calling the native normalize on that path (c.f. below for another likely bug discovered in TclFSNormalizeToUniquePath). To fix the issue in TclpObjNormalizePath, I would propose simply checking whether realpath has transformed a relative path into an absolute one and if yes, falling back to the slow method. I have verified that this situation only comes up in a few edge case tests in fileSystem.test when running the complete testsuite: ---- filesystem-1.33 start TclpObjNormalizePath: realpath relative -> absolute: 'C:' -> '/tmp/C:' ---- filesystem-7.2 start TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' ---- filesystem-7.4 start TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' ---- filesystem-7.5 start TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' ---- filesystem-7.6 start TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' ---- filesystem-7.7 start TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' ---- filesystem-7.8 start TclpObjNormalizePath: realpath relative -> absolute: 'simplefs:' -> '/ tmp/simplefs:' a patch to tclUnixFCmd.c implementing this workaround is below, it fixes the failure in filesystem-7.8 on Darwin. If you agree, I would like to commit this for 8.5a4. As to the likely bug in TclFSNormalizeAbsolutePath, it appears that the check for fsRecPtr == &nativeFilesystemRecord can fail even if fsRecPtr actually contains the native filesystem: (gdb) p &nativeFilesystemRecord $1 = (FilesystemRecord *) 0x146c7c (gdb) p *(&nativeFilesystemRecord) $2 = { clientData = 0x0, fsPtr = 0x146c00, fileRefCount = 1, nextPtr = 0x0, prevPtr = 0x7c9068 } (gdb) p fsRecPtr $3 = (FilesystemRecord *) 0x7c9008 (gdb) p *fsRecPtr $4 = { clientData = 0x0, fsPtr = 0x146c00, fileRefCount = 1, nextPtr = 0x0, prevPtr = 0x7c9088 } this results in the normalize function for the native FS to be called last instead of first as intended /* * Call each of the "normalise path" functions in succession. This is a * special case, in which if we have a native filesystem handler, we call * it first. This is because the root of Tcl's filesystem is always a * native filesystem (i.e. '/' on unix is native). */ one way to fix this might be to change tests for the native FS in tclIOUtil.c as follows -if (fsRecPtr == &nativeFilesystemRecord) { +if (fsRecPtr->fsPtr == nativeFilesystemRecord.fsPtr) { however, it would probably be better to figure out why the record for the native FS in filesystemList can become different from nativeFilesystemRecord in the first place, I haven't looked into this. Note that this second bug has no impact on the filesystem-7.8 failure, as the native normalize is still called on 'simplefs:/simpledir' at some point in TclFSNormalizeToUniquePath even if the check is changed as above. Index: unix/tclUnixFCmd.c =============================================== ==================== RCS file: /cvsroot/tcl/tcl/unix/tclUnixFCmd.c,v retrieving revision 1.52 diff -u -p -r1.52 tclUnixFCmd.c --- unix/tclUnixFCmd.c25 Mar 2006 01:32:11 -00001.52 +++ unix/tclUnixFCmd.c28 Mar 2006 08:14:43 -0000 @@ -1884,8 +1884,17 @@ TclpObjNormalizePath( nativePath = Tcl_UtfToExternalDString(NULL, path, lastDir-path, &ds); if (Realpath(nativePath, normPath) != NULL) { -nextCheckpoint = lastDir - path; -goto wholeStringOk; +if (*nativePath != '/' && *normPath == '/') { + /* + * realpath has transformed a relative path into an + * absolute path, we do not know how to handle this. + */ + fprintf(stderr, "TclpObjNormalizePath: realpath relative -> absolute\n"); + Tcl_DStringFree(&ds); +} else { + nextCheckpoint = lastDir - path; + goto wholeStringOk; +} } } } - login: "das"
- mimetype: "text/plain"
- priority changed to: "9 Immediate"
- username: "das"