Artifacts Associated With Ticket 3111059fffffffff
Ticket change [9a47fba070] (rid 110925) by msofer on 2010-11-17 21:46:46:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- comment initialized to:
As found by coldstore, simplified by dkf and ferrieux: the following leaks, a lot while 1 { namespace eval foo { proc bar {} yield coroutine coro bar namespace delete ::foo } } - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "msofer"
- subsystem initialized to: "60. NRE and coroutines"
- title initialized to: "coro+proc+ns deadlock"
- type initialized to: "Bug"
Ticket change [bcee327164] (rid 101830) by msofer on 2010-11-18 04:47:24:
- priority changed to: "8"
Ticket change [472fdc2813] (rid 99653) by msofer on 2010-11-18 05:19:53:
- icomment:
At least the namespace, proc and coro structs are all being leaked. This should not happen, the sequence going something like this when "namespace delete" is called: 1. Tcl_DeleteNamespace calls Tcl_DeleteCommandFromToken on [coro]'s cmdPtr 2. Tcl_DeleteCommandFromToken set cmdPtr->flags|=CMD_IS_DELETED and calls cmdPtr->deleteProc (== DeleteCoroutine) 3. DeleteCoroutine sees that coroPtr is suspended and: (a) pushes a callback for RewindCoroutine, (b) runs all callbacks 4. RewindCoroutine sets corPtr->eePtr->rewind=1 and resumes the coroutine 5. on resuming, TEBC sees the rewind flag and returns an uncatchable error: the nre stack is wound down to the bottom of the coroutine 6. the last callback on the coros execEnv is NRCoroutineExitCallback, coroutine deletion proceeds 7. ... Problem seems to be before or around step 5, as the proc should be freed when it returns.
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [8d1002bf97] (rid 127858) by ferrieux on 2010-11-18 05:39:14:
- icomment:
In that sequence, what role does the [proc] play ? Indeed, the same system with a non-proc coro _doesn't_ leak: while 1 { namespace eval foo { coroutine coro yield namespace delete ::foo } } - login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [7468efc0cf] (rid 105199) by ferrieux on 2010-11-18 05:50:25:
- icomment:
Yay ! DeleteCoroutine is *not* called in the leaky case.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [7076065096] (rid 100484) by ferrieux on 2010-11-18 05:55:17:
- icomment:
In fact, in Tcl_DeleteNamespace the coroutine test if (cmdPtr->nreProc == NRInterpCoroutine) { fails, because the value of cmdPtr->nreProc at this point is TclNRInterpProc Is that simply a typo ? - login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [aa86e5666b] (rid 100941) by ferrieux on 2010-11-18 06:09:33:
- icomment:
This is consistent with the proc/nonproc observation: the leak is correlated with the presence of a proc in the coro. As though the TclNRInterpProc was somehow "hiding" the underlying NRInterpCoroutine...
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [6a2f1902f8] (rid 128099) by ferrieux on 2010-11-18 07:03:29:
- icomment:
As a confirmation, the following doesn't leak: proc gbar {} yield while 1 { namespace eval foo { coroutine coro ::gbar namespace delete ::foo } } So, the key is the proc belonging to the NS, not the coro resume command. The leak is thus a consequence of the global delayed-NS-teardown policy. The fix, as Colin mentions on the chat, is probably to insist on applying the coro special case (sync teardown) in that case. - login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [53cf6b572d] (rid 93819) by ferrieux on 2010-11-18 07:36:01:
- icomment:
OK, after a bit of explanation by Miguel: that test tries to loop over commands, zapping coros. The TclNRInterpProc value is a red herring, meaning just that the scan sees the 'bar' proc. However, the bug is that 'coro' is not found. In this case this seems to be a flaw in the hashtable scanning logic used here: - first entry extracted is the proc 'bar' - since it is a proc, nothing is done to it - but the iteration step does "entryPtr = entryPtr->nextPtr" which is the next IN THE BUCKET - here it was alone in its bucket, which ends the loop prematurely. Fix: probably use something like search.nextEntry instead of entryPtr->nextPtr.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [e57b6f9db0] (rid 104130) by msofer on 2010-11-18 07:46:25:
- closedate changed to: "2010-11-18T00:46:25"
- closer changed to: "msofer"
- icomment:
allow_comments - 1 Spot on. Fixed in head
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "msofer"
Ticket change [066c760846] (rid 89224) by dkf on 2010-11-18 17:11:12:
- icomment:
Confirmed. Added some tests I had (to oo.test) that neatly spotted the issue.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [47f2dae55d] (rid 99799) by dgp on 2010-11-18 22:09:19:
- closedate changed to: "2010-11-18T15:09:19"
- closer changed to: "dgp"
- icomment:
allow_comments - 0 Any backporting needed for this?
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Pending"
- username: "dgp"
Ticket change [511bb8a39f] (rid 126085) by msofer on 2010-11-18 22:12:01:
- icomment:
No: the code is a special casing for coroutines which do not exist in previous versions
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [6c36e91111] (rid 128462) by msofer on 2010-11-18 22:12:02:
- closedate changed to: "2010-11-18T15:12:02"
- closer changed to: "msofer"
- icomment:
allow_comments - 1
- login: "msofer"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "msofer"