| Ticket UUID: | 3479689 | ||
| Title: | shimmer 0-refcount to path can segfault | ||
| Type: | Bug | Created on: | 2012-01-25 17:43:37 |
| Submitter: | dgp | Assigned to: | dgp |
| Subsystem: | 37. File System | Severity: | |
| Priority: | 8 | Last modified: | 2012-01-28 04:58:05 |
| Status: | Closed | Closed by: | dgp |
| Resolution: | Fixed | Closed on: | 2012-01-27 21:58:05 |
| Version: | obsolete: 8.5.11 | ||
| Description: | ||||
Tcl_FSConvertToPathType(NULL, Tcl_NewStringObj("a//b",-1));
will crash at least on unix systems in a -enable-symbols=mem build
of Tcl.
This passes a 0-refcount value to SetFsPathFromAny() which
passes it on to Tcl_FSJoinToPath(). As documented, on exit
Tcl_FSJoinToPath() frees the value, but then SetFsPathFromAny()
continues on, trying to build a "path" intrep in the freed space. BOOM!
| ||||
| User Comments: | ||||
dgp added on 2012-01-26 00:48:27:
In the more usual build, this won't crash, but will result in building up the path value in a Tcl_Obj that's been returned to the free pool. Eventually that will get reallocated to some other use, and you'll see memory corruption effects as two different owners battle over the use of the struct. dgp added on 2012-01-26 01:30:06:
The quick and easy fix is to bracket the
call to Tcl_FsJoinToPath() with refcount incr/decr:
pathPtr->refCount++;
transPtr = Tcl_FSJoinToPath(pathPtr, 0, NULL);
pathPtr->refCount--;
dgp added on 2012-01-26 01:31:23:
The more attractive fix is to take Tcl_FSJoinToPath() back behind the barn and shoot it in the head. Why oh why do we document interfaces we can plainly see are broken? dgp added on 2012-01-26 23:43:56:
Simple fix committed for 8.5.12 dgp added on 2012-01-28 04:58:05:
allow_comments - 1 Better fix on trunk with refactoring of the *Join*Path* routines into more usable interfaces. | ||||
