Thread-unsafe handling of cwdPathPtr
Closed / Fixed710642ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2003-03-27 10:27:22
The new pluggable filesystem code located in generic/tclIOUtils.c naively plays with global Tcl_Obj*, passing them between threads per-reference and neglecting the proper locks for all except write operations. The spot in question is the global Tcl_Obj *cwdPathPtr. The net-effect is that paths passed to the OS-calls gets garbled, memory is being trashed leading to process exitus and whole bunch of other ugly things is happening. I think this has to be entirely revised, as one can not simply share Tcl_Objs between threads. One has to always make a deep-copy (w/o internal references) of the object before passing it to some other thread. I have some ideas on how to solve this, but it is really not that straight-forward, since few of design issues have to be modified. This bug is really a show-stopper for MT-apps therefore the highest priority.
vasiljevicplain2003-03-28 23:28:02
File Added - 46156: tclIOUtil.c Logged In: YES user_id=95086 Here is my reworked version which uses char* to hold the cwd. I know it is not 100% good because a path may contain NULL chars. We might improve this and store char* and its length. The Tcl_Obj is really not usable in MT-environments since it can't be deep-copied with the current duplicate function (i mean path objects). Anyways, the entire file is attached.
vincentdarleyplain2003-04-01 00:35:41
Logged In: YES user_id=32170 Can you provide a unified diff (diff -u) for easier analysis, please?
vasiljevicplain2003-04-02 16:10:51
Logged In: YES user_id=95086 Sure. It is attached. I did the diff against the 8.4.2 version. Note that I've used some pretty conservative locks in Tcl_FSGetCwd and Tcl_FSChdir. This may be relaxed eventually.
vasiljevicplain2003-04-02 16:11:44
File Added - 46565: tclIOUtil.c.diff
vincentdarleyplain2003-04-11 23:35:49
Logged In: YES user_id=32170 I'll be looking into this soon, now I've resolved the various other bugs I was working on. Your code looks like a good template, but I'd like to remove the need for 'inner' functions.
hobbsplain2003-05-11 08:23:25
File Added - 50090: tclIOUtil.c.patch.710642 Logged In: YES user_id=72656 I've attached Zoran's latest version (with one minor change to init char *str) and commited that to core-8-4-branch. We need a version for the HEAD. It would also be nice to have some sort of tests that exercise this (if possible).
vincentdarleyplain2003-05-13 21:24:48
Logged In: YES user_id=32170 Zoran says this should also apply to cvs head.
hobbsplain2003-05-14 06:00:25
Logged In: YES user_id=72656 Applied to head with offsets.
Log in (anonymous is fine) to add a comment.
Attachments:
- tclIOUtil.c.patch.710642 [download] added by hobbs on 2003-05-11 08:23:25. [details]
- tclIOUtil.c.diff [download] added by vasiljevic on 2003-04-02 16:11:44. [details]
- tclIOUtil.c [download] added by vasiljevic on 2003-03-28 23:28:02. [details]