| Ticket UUID: | 451328 | ||
| Title: | thread problem with Tcl_GetStringFromObj | ||
| Type: | Bug | Created on: | 2001-08-15 21:42:49 |
| Submitter: | stevenashe | Assigned to: | andreas_kupries |
| Subsystem: | 49. Threading | Severity: | |
| Priority: | 5 Medium | Last modified: | 2001-08-21 00:35:31 |
| Status: | Closed | Closed by: | andreas_kupries |
| Resolution: | Invalid | Closed on: | 2001-08-20 17:35:31 |
| Version: | obsolete: 8.4a3 | ||
| Description: | ||||
Hello. Might there is a problem with Tcl_GetString[FromObj]? As the code [but not the man page :-( ] indicates, the result is transient, pending some other call that changes the internal representation in the object. In a preemptive threaded environment, that "other call" can happen asynchronously, meaning that the return value from Tcl_GetStringFromObj is guaranteed valid at NO time (!); there is no guarantee the user can even copy the data. Either I'm being stupid, or this would seem to be something of a problem. | ||||
| User Comments: | ||||
andreas_kupries added on 2001-08-16 08:52:18:
Logged In: YES user_id=75003 Tcl follows the one thread per interp model. This means one thread may contain a complete hierarchy of interpreters, but all interpreters in that hierarchy may only be accessed by their thread and _no_ other. For Tcl_Obj's this implies that an object with a refcount > 1 must not be shared between interpreters in different threads. Else the complications mentioned above arise. To access some information in more than one thread it is necessary to duplicate the object in question and then transfer this unshared object via an event to the other thread. davygrvy added on 2001-08-16 09:04:50:
Logged In: YES user_id=7549 As Andreas says correctly, your assumption of thread safety with Tcl's API is out-of-bounds with its intended design. See http://dev.scriptics.com/doc/howto/thread_model.html See the thread extension also for how to share variables across threads. You can pass Tcl_Obj pointers to threads just fine. Just don't do any operations on them. | ||||
