Tcl Source Code

View Ticket
Login
Ticket UUID: ef34dd2457472b08cf6a42a7c8c26329e2cae715
Title: fileevent writable starves bgerror
Type: Bug Version: 8.6.1
Submitter: pooryorick Created on: 2013-11-14 15:41:51
Subsystem: 02. Event Loops Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2014-07-10 19:19:17
Resolution: Rejected Closed By: anonymous
    Closed on: 2014-07-10 19:19:17
Description:
In the code below, both the readable and writable event scripts are executed, but bgerror never runs because the queue is dominated by the fileevent events.

----

#! /bin/env tclsh

proc handler {arg} {
    return -code error "an error!"
}

lassign [chan pipe] pipeout pipein
set stdout [open |[list echo hello]]
fileevent $pipein writable {apply {{} {}}}
fileevent $stdout readable [list handler $stdout]

vwait exit
User Comments: anonymous added on 2014-07-10 19:19:17:
"anonymous" is Simon Bachmann...
I tried to register but I keep getting "Connection was reset" errors...

ferrieux added on 2014-07-06 23:26:37:
Right, but ... any hope to put a name behind "anonymous" ?

anonymous added on 2014-07-06 20:42:21:
Not a bug, works just like it should.

from the manpage of bgerror(n):
"When Tcl detects a background error, it  saves  information  about  the error  and invokes a handler command registered by interp bgerror later as an 
idle event handler."
^^^^^^^^^^^^^^^^^^^

...and Tcl_DoOneEvent(3) states that idle callbacks are processed only once there are no other events to process.

In the example, the event loop never gets a chance to do idle callbacks (and bgerror _is_ an idle callback) because there's always a [fileevent readable] event.