Overview
| Artifact ID: | e22d88bc21383820c1c85ff725e46a9cfa4234bfc577ccd17cf74bb284e9ad39 |
|---|---|
| Ticket: | 61c01e0edb08a9ed905aefdf17ce113da303c77b
likely race condition with package require in several threads causing error |
| User & Date: | sebres on 2025-07-18 15:24:00 |
Changes
- icomment:
Weird. The FS-API of Tcl (at least for Windows) doesn't look thread safe to me now. Debugging a bit, I see following picture in TclpMatchInDirectory: ``` # correct behaviour of glob: ==68b0==B0== D:/Projects/tcllib/build_9.x/lib => D:/Projects/tcllib/build_9.x/lib (32) ==68b0==B1== D:/Projects/tcllib/build_9.x/lib => D:/Projects/tcllib/build_9.x/lib (32) ==68b0==B2== D:/Projects/tcllib/build_9.x/lib => D:/Projects/tcllib/build_9.x/lib/ ==68b0==BE== D:/Projects/tcllib/build_9.x/lib/* ... # wrong behaviour of glob: ==68b0==B0== D:/Projects/tcllib/build_9.x/lib => D:/Projects/tcllib/build_9.x/lib (32) ==68b0==B1== D:/Projects/tcllib/build_9.x/lib => D:/ (-1) ==68b0==B2== D:/Projects/tcllib/build_9.x/lib => D:// ==68b0==BE== D://* ... ``` B0 shows `fileNamePtr` as result of `fileNamePtr = Tcl_FSGetNormalizedPath(interp, pathPtr)`;<br/> B1 shows the same `fileNamePtr`, but after invocation of `Tcl_FSGetNativePath(pathPtr)`. Somewhere in between, the path object invalidates its normalized representation (`pathPtr->normPathPtr`), probably by epoch change, so `fileNamePtr` becomes invalid (since it is used not incremented inside of function). This grave bug exists at least since 8.5, just probably since 8.7 or 9.0 the epoch changes often for some reason, so invalidation of object happens more often and behaviour gets noticeable in threaded environment. But after all it is typical use-after-free and can cause crash with SF or BO, memory corruption etc. I'll fix it now for all branches. I guess, besides complete code review (to find similar issues), we have to re-release several versions hereafter or at least provide hotfixes for that.
- login: "sebres"
- mimetype: "text/x-markdown"
- priority changed to: "9 Immediate"