Tcl Source Code

View Ticket
Login
2024-11-15
12:58 Ticket [67a5eabbd3] refchan, coroutine, and postevent from the "watch" proc status still Closed with 3 other changes artifact: 8660235308 user: pooryorick
2024-11-04
21:50 Ticket [67a5eabbd3]: 3 changes artifact: e83c953e75 user: pooryorick
2024-06-11
07:14 Closed ticket [67a5eabbd3]. artifact: c03c344bb7 user: jan.nijtmans
2024-06-04
06:20 Open ticket [67a5eabbd3]. artifact: f00ef55e9a user: pooryorick
2024-06-03
13:22 Closed ticket [67a5eabbd3]. artifact: 55a38fdfc2 user: oehhar
09:43 Open ticket [67a5eabbd3]. artifact: 0e254036f2 user: pooryorick
09:35 Closed ticket [67a5eabbd3]. artifact: 53260183db user: oehhar
09:32 Open ticket [67a5eabbd3]. artifact: 1a55793c5f user: pooryorick
09:31 Closed ticket [67a5eabbd3]. artifact: 8a6977f069 user: oehhar
09:25 Open ticket [67a5eabbd3]. artifact: 3a77951e3b user: pooryorick
09:03 Closed ticket [67a5eabbd3]. artifact: a4a0907176 user: oehhar
08:47 Open ticket [67a5eabbd3]. artifact: e86f08bd0c user: pooryorick
08:33 Closed ticket [67a5eabbd3]. artifact: 9e420b8c0b user: jan.nijtmans
08:15 Open ticket [67a5eabbd3]. artifact: ea20a216c3 user: pooryorick
08:09 Closed ticket [67a5eabbd3]. artifact: b7888c22c3 user: oehhar
07:53 Ticket [67a5eabbd3]: 3 changes artifact: f9cb7c51c6 user: pooryorick
07:52 Open ticket [67a5eabbd3]. artifact: 8523c45ef1 user: pooryorick
07:35 Closed ticket [67a5eabbd3]. artifact: 8b933955e5 user: oehhar
06:49 Open ticket [67a5eabbd3]. artifact: df21f570b1 user: pooryorick
05:56 Closed ticket [67a5eabbd3]. artifact: f61d4fc92f user: oehhar
2024-06-02
21:01 Open ticket [67a5eabbd3]. artifact: 5a521c00e2 user: pooryorick
17:04 Closed ticket [67a5eabbd3]. artifact: 33d15a5c58 user: oehhar
2024-05-31
11:20 Open ticket [67a5eabbd3]. artifact: d63d420ceb user: pooryorick
11:10 Closed ticket [67a5eabbd3]. artifact: 209cf68729 user: jan.nijtmans
10:25 Open ticket [67a5eabbd3]. artifact: 9a8c853af8 user: pooryorick
10:13 Ticket [67a5eabbd3]: 5 changes artifact: 8d1f0ac60b user: pooryorick
2024-05-29
09:49 Ticket [67a5eabbd3]: 6 changes artifact: 8fe838e082 user: jan.nijtmans
2024-04-19
08:34 Ticket [080f846fd5] Channel system generating writable events BEFORE channel is open (refchan) status still Open with 3 other changes artifact: 1d6bd02ad7 user: pooryorick
2024-04-18
15:04 Ticket [080f846fd5]: 3 changes artifact: 85049380dd user: jan.nijtmans
2024-03-31
01:12 Ticket [de232b49f2] write-only nonblocking refchan and Tcl internal buffers status still Open with 3 other changes artifact: 838d4d73fe user: pooryorick
2021-06-20
05:15 Closed ticket [67a5eabbd3]: refchan, coroutine, and postevent from the "watch" proc plus 4 other changes artifact: 71eea3d9e2 user: pooryorick
05:14 Ticket [67a5eabbd3]: 3 changes artifact: 1804967dd5 user: pooryorick
2021-06-16
21:24 Ticket [67a5eabbd3]: 3 changes artifact: 472da83a75 user: pooryorick
17:15 Ticket [67a5eabbd3]: 3 changes artifact: 46c4cc07ea user: dgp
16:06
Re-apply fix for [67a5eabbd3d1]: refchan, coroutine, and postevent from the "watch" proc check-in: f6aa52e243 user: pooryorick tags: core-8-branch
13:23
Re-apply fix for [67a5eabbd3d1]: refchan, coroutine, and postevent from the "watch" proc Leaf check-in: 0037b3d176 user: jan.nijtmans tags: bug-67a5eabbd3d1
10:30 Open ticket [18f4a94d03]: 8.7 : a blocking memory channel no longer works. plus 5 other changes artifact: b9c8e0111c user: pooryorick
2021-06-15
14:58 Pending ticket [67a5eabbd3]: refchan, coroutine, and postevent from the "watch" proc plus 6 other changes artifact: f2c6446ced user: jan.nijtmans
12:46 Ticket [18f4a94d03] 8.7 : a blocking memory channel no longer works. status still Open with 4 other changes artifact: c3d29a0d48 user: jan.nijtmans
2019-04-29
09:07 Ticket [67a5eabbd3] refchan, coroutine, and postevent from the "watch" proc status still Closed with 4 other changes artifact: c19eb03a7a user: pooryorick
2019-04-26
20:42 Closed ticket [67a5eabbd3]. artifact: bd098f6728 user: pooryorick
2019-04-24
04:57 Pending ticket [ef28eb1f15]: TCL_FILE_EVENTS cannot drive async I/O alone plus 4 other changes artifact: e3eeb351db user: pooryorick
04:53 Pending ticket [67a5eabbd3]: refchan, coroutine, and postevent from the "watch" proc plus 2 other changes artifact: 9c1e691b06 user: pooryorick
2019-04-23
13:02 Ticket [67a5eabbd3]: 3 changes artifact: ade7a3766c user: pooryorick
11:29
Fix for [67a5eabbd3d1], refchan, coroutine, and postevent from the "watch" proc. check-in: e066e24f36 user: pooryorick tags: bug-67a5eabbd3d1
2016-10-09
15:47 Ticket [67a5eabbd3] refchan, coroutine, and postevent from the "watch" proc status still Open with 3 other changes artifact: fefa233cb0 user: dkf
2016-09-06
23:43 Ticket [67a5eabbd3]: 3 changes artifact: fd3dd8909f user: ferrieux
20:36 Ticket [67a5eabbd3]: 4 changes artifact: ea38695639 user: pooryorick
2016-08-15
12:03 Ticket [67a5eabbd3]: 3 changes artifact: 3b3d6f403f user: ferrieux
11:58 Ticket [67a5eabbd3]: 3 changes artifact: 68f70483aa user: ferrieux
11:53 Ticket [67a5eabbd3]: 3 changes artifact: 69ab5e522b user: aspect
10:31 New ticket [67a5eabbd3]. artifact: c68462dbc9 user: pooryorick

Ticket UUID: 67a5eabbd3d195915d3ccc13246bdecf10e20726
Title: refchan, coroutine, and postevent from the "watch" proc
Type: Bug Version: 8.6.6
Submitter: pooryorick Created on: 2016-08-15 10:31:45
Subsystem: 60. NRE and coroutines Assigned To: apnadkarni
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2024-11-15 12:58:34
Resolution: Wont Fix Closed By: jan.nijtmans
    Closed on: 2024-06-11 07:14:31
Description:

The following script results in an error to the effect that the coroutine is already running.

#! /bin/env tclsh

interp bgerror {} [list apply {{res opts} {
    puts stderr [dict get $opts -errorinfo]
    exit 1
}}]

namespace eval schan {
    namespace ensemble create
    namespace export *
    proc open {} {
        variable chans
        set chan [chan create read [namespace current]]

    }
    proc initialize {chan mode} {
        return [list initialize finalize read watch]
    }

    proc read {chan count} {
    }

    proc watch {chan eventspec} {
        chan postevent $chan $eventspec
    }
}

coroutine c1 apply [list {} {
    set chan [schan::open]
    chan event $chan readable [list [info coroutine]]
    yield
    puts thiswillnotappear
}] 
vwait ::forever

User Comments: pooryorick added on 2024-11-15 12:58:34:

On the "unchained" branch test iocmd-31.9 tests this issue.


pooryorick added on 2024-11-04 21:50:00:

This issue remains fixed on the "unchained" branch. The stated rationale for rolling back the fix for this issue, "completely nullifies the purpose of event-driven i/o", is not only false on that branch since event-driven i/o operates as expected, with write events being generated only when the underlying device is writable, but is orthogonal to the issue raised here.


oehhar added on 2024-06-03 09:35:06:
We had a meeting today. Today, it is my duty to close the tickets.
Sorry, the others are not available today. We have to share resources...

Thank you for your comprehension,
Harald

pooryorick added on 2024-06-03 08:15:48:

This issue should remain open until [67a5eabbd3d19591] is resolved.


oehhar added on 2024-06-03 08:09:34:
Dear Nathan,

thank you for reporting this documentation issue. Please report it in a different ticket.

Thank you for your comprehension,
Harald

pooryorick added on 2024-06-02 21:01:04:

No, the documentation for [chan postevent] does not indicate that this is expected behaviour, so this report should remain open.


oehhar added on 2024-06-02 17:04:37:

Sorry Nathan ! As informed on the core list:

  • This is a RFE, not a bug. It will not work with the current design.
  • The only way to change this is a TIP

In consequence, it is changed to a RFE and closed with the state "wont fix".

Thank you for your comprehension, Harald


pooryorick added on 2024-05-31 11:20:36:

It is not clear to me that this is a duplicate of [d3232b49f2], so I'm reopening it.


jan.nijtmans added on 2024-05-31 11:10:36:

Dup of [de232b49f2]


jan.nijtmans added on 2024-05-29 09:49:25:

This 'bug-fix' is backed-out, see here for the full motivation. Backout approved by the TCT.


pooryorick added on 2021-06-16 21:24:47:

Yes, that's an accurate summary, as the call to Tcl_NotifyChannel is moved into a timer event handler.


dgp added on 2021-06-16 17:15:04:
Can the patch be described accurately as changing to operations
of the [chan postevent] command from synchronous to asynchronous?

jan.nijtmans added on 2021-06-15 14:58:25:

Backed out because of [18f4a94d03]. Therefore re-opening this one.


pooryorick added on 2019-04-23 13:02:56:

Fixed in [e066e24f36f67a8d] by using Tcl_CreateTimerHandler() to schedule the call to Tcl_NotifyChannel().


ferrieux added on 2016-09-06 23:43:17:
FWIW, some time ago, async fcopy suffered from a similar "premature callback" issue: in some circumstances, where the copy was provably complete, the completion callback fired from within fcopy instead of from the event loop  (despite the async flag).

It was Obviously Wrong, and fixed. I'm tempted to follow your suggestion and propose the same here, though I don't know the details of the refchan enough to be sure of the analogy.

Maybe Andreas could chime in.

pooryorick added on 2016-09-06 20:36:03:

This happens because chan postevent calls Tcl_NotifyChannel() instead of scheduling an event, as explained in ef28eb1f15167156c898.


ferrieux added on 2016-08-15 12:03:52:
Hum, never mind, simple interp bgerror playing its role, sorry.

ferrieux added on 2016-08-15 11:58:39:
Interesting: it's not even a vanilla error, it's uncatchable !
It sorta reaches the default "spit out errorInfo and exit(1)", regardless of any [catch] range.
Digging...

aspect added on 2016-08-15 11:53:46:
The stack trace of the error is:
 c1
  chan event
   schan::watch
    c1 (boom!)

ie, yield is not even reached.

schan::watch should not immediately call [chan postevent].  Wrapping that in [after 0] removes the crash, but I'm not sure this is correct behaviour for postevent either.

See tcllib or http://chiselapp.com/user/aspect/repository/tcl-hacks/artifact/6cb89e9c9ebb6800 for other strategies (but I now see potentially a similar bug in the chiselapp link ..)