Overview
| Artifact ID: | 62c65d4132c56c3e992ee0e728ebbd9c5d8092af |
|---|---|
| Ticket: | 992108ffffffffffffffffffffffffffffffffff
TclFinalizeLock on Unix not correct. |
| User & Date: | vasiljevic on 2004-07-17 17:37:34 |
Changes
- icomment:
Logged In: YES user_id=95086 OK. The remaining thing to be resolved here is: pthread_mutex_unlock(&initLock); pthread_mutex_destroy(&initLock); Theoretically, you have a classcal race condition here. If two threads attempt to call Tcl_Finalize, at the moment you release the initLock mutex in the first thread, the other thread starts the calling TclFinalizeLock() and you go thru the call twice, destroying the already destroyed allocLock, masterLock and initLock mutexes. This is very tricky to solve correctly. You may do pthread_mutex_destroy(&allocLock), allocLock = NULL; pthread_mutex_destroy(&masterLock), masterLock = NULL; to avoid these two traps (in which case current freebsd implementation will return EINVAL) but you're left with the potential hazardous initLock where you can go and hit the destroyed but not re-initialized mutex and definitely get the segmentation at the line: _SPINLOCK(&(*mutex)->lock); in pthread_destroy_mutex() In order to avoid this, you must get yet another mutex and the story repeats. Eventually, you must at least accept one leaked mutex (the initLock). I see no other possibility. Do you?
- login: "vasiljevic"
- mimetype: "text/plain"
- username: "vasiljevic"