|
2009-05-08
| ||
| 09:03 | • Closed ticket [2153080fff]: coroutine deletion, yield should error plus 7 ot... artifact: 7d8a10c293 user: msofer | |
|
2009-05-01
| ||
| 08:26 | • Ticket [2153080fff]: 1 change artifact: fdca85f2b1 user: msofer | |
| 08:24 | • Ticket [2153080fff]: 1 change artifact: 3b4fe32f6a user: msofer | |
|
2008-10-08
| ||
| 22:10 | • Ticket [2153080fff]: 4 changes artifact: df14406fe7 user: msofer | |
| 19:28 | • Ticket [2153080fff]: 1 change artifact: ed24c55c37 user: dkf | |
| 19:28 | • Ticket [2153080fff]: 6 changes artifact: 3967026f86 user: dkf | |
| 12:20 | • New ticket [2153080fff]. artifact: 9365c160c4 user: nobody | |
coroutine deletion, yield should error
Closed / Fixed2153080fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-10-08 12:20:22
if one deletes a coroutine by [rename [info coroutine] {}] and then calls [yield], the coroutine is never deleted and can never be deleted, as only a [return] will effect the deletion and after [yield] the coroutine can never be called again in order to return.
I suggest that both [yield] and [info coroutine] should raise an error if called from a deleted coroutine, which would cause the deletion cleanup.
Alternatively, [yield] should effect the cleanup. Note, [info coroutine] returns a fully ns-qualified {} name.
- Colin.
dkfplain2008-10-08 19:28:15
In what way (apart from the erroneous result from [info coroutine]) is there a problem? What resource is being consumed?
% proc foo args {puts "DEBUG: $args"}
% proc bar {} {trace add variable v unset foo;yield;rename [info coro] {};puts IN;yield;puts END}
% coroutine spong bar
% trace add command spong delete foo
% info commands
tell socket subst open eof pwd glob list pid exec auto_load_index time unknown eval lassign lrange fblocked lsearch auto_import gets case lappend proc break llength variable auto_execok return linsert error catch clock info split array if fconfigure coroutine concat join lreplace source fcopy global switch auto_qualify update foo bar close cd for auto_load file append lreverse format unload read package set binary namespace scan apply spong trace seek while chan flush after vwait dict continue uplevel foreach lset rename fileevent regexp lrepeat tailcall upvar encoding expr unset load regsub history interp exit puts incr lindex lsort tclLog string yield
% spong
DEBUG: ::spong {} delete
IN
DEBUG: v {} unset
% info commands
tell socket subst open eof pwd glob list pid exec auto_load_index time unknown eval lassign lrange fblocked lsearch auto_import gets case lappend proc break llength variable auto_execok return linsert error catch clock info split array if fconfigure coroutine concat join lreplace source fcopy global switch auto_qualify update foo bar close cd for auto_load file append lreverse format unload read package set binary namespace scan apply trace seek while chan flush after vwait dict continue uplevel foreach lset rename fileevent regexp lrepeat tailcall upvar encoding expr unset load regsub history interp exit puts incr lindex lsort tclLog string yield
dkf Ticket [2153080fff]: 1 change
[History diff]2008-10-08 19:28:28
msoferplain2008-10-08 22:10:31
I tend to agree with dkf: the main problem is (was, fix now committed) that [info coro] was returning a wrong name. As returning an error from [info] is not really an option, the fix is that it will now return {}.
The new interpretation for [info coro] returning {} is: "there is no command that will resume this coroutine". That happens for one of two reasons:
- no coroutine is running
- the command to resume the running coroutine has been deleted
msofer Ticket [2153080fff]: 1 change
[History diff]2009-05-01 08:24:17
msofer Ticket [2153080fff]: 1 change
[History diff]2009-05-01 08:26:40
msoferplain2009-05-08 09:03:47
allow_comments - 1
To be clear: the coroutine IS deleted after that yield - the command is marked as deleted when renamed to {}, and effectively deleted when it yields. The proof: run the following script (under nice, tight busy loop!) and watch the memory it uses: it is constant.
proc a {} {
puts -nonewline .
flush stdout
rename [info coroutine] {}
yield
}
while 1 {
coroutine b[incr i] a
}
Log in (anonymous is fine) to add a comment.