Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: db9d293045cbc912ed122ff5079901a9144c335c
Ticket: 39bb9b3ebb5ea83c4037980750b2c7a8929ff624
deleting a coroutine bypasses try..finally handlers
User & Date: aspect on 2015-11-11 04:29:36
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    When a coroutine is deleted by [rename] or through deletion of its namespace,
    finally handlers are not invoked:
    
    
    % coroutine foo try yield finally {puts ok}
    % rename foo {}
    
    % namespace eval foo { coroutine foo try yield finally {puts ok} }
    % namespace delete foo
    
    Delete traces do fire, providing a sort of workaround:
    
    % coroutine foo apply {{{t 0}} {
        trace add variable t unset {puts ok; list}
        yield
    }}
    % rename foo {}
    ok
    
    Arguably this might not be a bug, but it renders [try .. finally] unreliable
    for resource deletion in the presence of coroutines.
    
    
    Miguel's previous comments from the chat:
    
    2015-08-09:
    
    <aspect> % coroutine c try yield finally {puts ok}; rename c {}   ;# no output
    <aspect> that makes deleting coroutines .. problematic
    <aspect> delete traces fire though:
    <aspect> % coroutine c apply {{{t 0}} {trace add variable t unset {puts ok;
             list}; yield}}; rename c {}   ;# emits "ok"
    
    <miguel> what is problemtic about deleting coroutines?
    <miguel> they self-delete when they return; you can delete them as normal
             commands otherwise - even from within
    <miguel> ohhh ... the finally never executed, right ... will look into it
    <miguel> (possibly a problem also for [interp cancel], as they share the
             mechanism iirc)
    <miguel> it is a fundamental problem - the classic invincible-force vs
             unmovable-object: "cancel everything no matter what" vs "before
             canceling you HAVE to do this one thing (which may require infinite
             resources)"
    <miguel> (at least in the [interp cancel] version)
    <miguel> % try {interp cancel -unwind} finally {puts ok}
    <miguel> eval unwound
     * miguel finds this not trivial at all
    <miguel> the problem is that the finally clause WILL get executed RIGHT AFTER 
             the try clause finishes - which happens to be NEVER in aspect's setup
    
    
    2015-11-11:
    
    <miguel> I have a vague recollection that we talked about it, and that I thought
             'not a bug' ...
    <miguel> ... finally meaning 'before this command returns', and your ops making
             sure that the command in question never returned ...
    <miguel> ... so that 'never' satisfies 'before the command returns'
    
  5. foundin changed to: "8.6.4"
  6. is_private changed to: "0"
  7. login: "aspect"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "a0e4455685fad6d7c7fc63ae05f16454df49fdf3"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "aspect"
  14. subsystem changed to: "60. NRE and coroutines"
  15. title changed to:
    deleting a coroutine bypasses try..finally handlers
    
  16. type changed to: "Bug"