Overview
| Artifact ID: | 4a284f53110f287121b3deb3355998903f914679e8c1dd3f3684f031db10c483 |
|---|---|
| Ticket: | f2ff05fc8411be80a93913b2b065f2c85fa9bcf0
Usage of static systemEncoding is not thread safe (vulnerability) |
| User & Date: | serhiy.storchaka on 2026-10-17 08:10:31 |
Changes
- foundin changed to: "9.0.5, 9.1.0"
- icomment:
Reproduced on 9.0 and main: one thread doing <nowiki>[file exists]</nowiki> on a long path while another switches <nowiki>[encoding system]</nowiki> crashes every run. Also Tcl_GetEncoding(NULL, NULL) returned systemEncoding read again after unlocking the mutex. Branch [/timeline?r=system-encoding-keep-retired|system-encoding-keep-retired] is a simple alternative to [/timeline?r=sebres-encoding-perf-branch|sebres-encoding-perf-branch]: former system encodings are kept until finalization, so a conversion can keep using the one it read, without a mutex or atomic reference counts. (The atomic reference count in sebres-encoding-perf-branch narrows the race but does not close it: the encoding can be freed between reading systemEncoding and incrementing its count.) A reference in each conversion with a mutex works too, but made <nowiki>[file exists]</nowiki> in 4 threads 1.75 times slower here. Visible change: a former system encoding is not unloaded when <nowiki>[encoding dirs]</nowiki> changes (encoding-2.2 adjusted). Test thread-9.1. We can find a better solution later, but it is better to fix the crash now.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"