| Ticket UUID: | 1048733 | ||
| Title: | possible segfaults with NULL interps | ||
| Type: | Bug | Created on: | 2004-10-17 16:36:45 |
| Submitter: | coldstore | Assigned to: | vincentdarley |
| 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: | ||||
FileCopyRename at ../generic/tclFCmd.c:539 calls Tcl_FSFileAttrsSet(NULL, 2, target, perm), passing a NULL Tcl_Interp* into the set attr command (presumably because the rename is being performed en passant) However, NativeFileAttrsSet() which is the default for normal file systems (and other set attribute handlers), can get errors - in my case in SetPermissionsAttribute at ../unix/tclUnixFCmd.c:1480, where a posix error occurs, and the code calls Tcl_PosixError(interp). The upshot is that Tcl_PosixError tries (eventually) to set errorCode and this fails because there is no interpreter (or, rather, a NULL interpreter) for it to set the variable in. You can reproduce this by creating a pair of files, A and B, owned by another user and (at least in my case) chmod u=rw,g=r,o=r Then, in tclsh8.5: file rename -force A B It SIGSEGVs because of the NULL interpreter. I suggest that the practice of passing NULL interp into functions which could generate errors is always bad, and in this case at least the call to Tcl_FSFileAttrsSet should pass in the variable interp, and not NULL. | ||||
| User Comments: | ||||
coldstore added on 2004-10-18 00:16:32:
Logged In: YES user_id=19214 At least the following public and private functions in tcl/generic/ match the following criteria: 1) have Tcl_Interp* as their first argument 2) have NULL passed in as their first argument. In the case that they (or the functions they pass interp to) can possibly error, I believe there's a risk of a segment fault. Tcl_Close Tcl_DictObjFirst Tcl_DictObjGet Tcl_DictObjPut Tcl_DictObjRemove Tcl_DictObjSize Tcl_ExternalToUtf Tcl_FSConvertToPathType Tcl_FSFileAttrsSet Tcl_FSGetCwd Tcl_FSGetNormalizedPath Tcl_FSGetTranslatedPath Tcl_FSJoinToPath Tcl_FSOpenFileChannel Tcl_GetBoolean Tcl_GetBooleanFromObj Tcl_GetEncoding Tcl_GetIndexFromObj Tcl_GetInt Tcl_GetIntFromObj Tcl_GetLongFromObj Tcl_GetWideIntFromObj Tcl_ListObjAppendElement Tcl_ListObjAppendList Tcl_ListObjGetElements Tcl_ListObjIndex Tcl_ListObjLength Tcl_ListObjReplace Tcl_ParseCommand Tcl_RegExpCompile Tcl_SetChannelOption Tcl_SplitList Tcl_UtfToExternal CheckForDeadChannel DoTildeSubst FlushChannel GetStatBuf SetBlockMode SetByteArrayFromAny SetFsPathFromAny SetStringFromAny coldstore added on 2004-10-18 00:30:05:
Logged In: YES user_id=19214 Winnowing out those functions which document that the can accept NULL interp arguments, we're left with these candidates for SEGV: Tcl_FSConvertToPathType Tcl_FSFileAttrsSet Tcl_FSGetCwd Tcl_FSGetNormalizedPath Tcl_FSGetTranslatedPath Tcl_FSJoinToPath Tcl_FSOpenFileChannel Tcl_GetBoolean Tcl_GetBooleanFromObj Tcl_GetEncoding Tcl_GetIndexFromObj Tcl_GetInt Tcl_GetIntFromObj Tcl_GetLongFromObj Tcl_GetWideIntFromObj Tcl_SetChannelOption CheckForDeadChannel DoTildeSubst FlushChannel GetStatBuf SetBlockMode SetByteArrayFromAny SetFsPathFromAny SetStringFromAny vincentdarley added on 2004-10-18 16:55:29:
Logged In: YES user_id=32170 The segfault cited has been fixed in cvs head a few weeks back. It would be worth looking at the other possible problems in more detail. dgp added on 2006-03-10 13:40:55:
Logged In: YES user_id=80530 where do we stand on this now? serhiy.storchaka added on 2026-10-21 10:03:39:
The reported crash (file rename -force calling Tcl_FSFileAttrsSet() with a NULL interp) was fixed in 8.5.0 by [088b6e6a3c] ([1020538]): the Unix attribute setters no longer touch a NULL interp on error. No crash with the other listed functions has been reported, so closing. | ||||
