[tkined] side effect in Tcl_NotifyChannel introduced in tcl8.0.3

Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Mon, 14 Sep 1998 10:22:44 +0200

Description:

Tcl_NotifyChannel (tclIO.c) has been modified in Tcl 8.0.3 to protect
the channel in a fileevent by adding calls to Tcl_RegisterChannel and
Tcl_UnregisterChannel. This modification seems to be related to the
following entry in the changes file:

: 12/8/97 (bug fix) Need to protect the channel in a fileevent so that it
: is not deleted before the fileevent handler returns. (CS, JL)

This fix has a side effect that breaks existing C code, in particular
extensions (for example the scotty extension which I am maintaining)
that use Tcl channels internally. These channels are usually not
registered as the extension knows when to close the channel. The
change in Tcl_NotifyChannel has the effect that the channel gets
registered and later unregistered for a NULL interpreter. The call to
Tcl_UnregisterChannel in Tcl_NotifyChannel now has the side effect
that the channel gets closed when the first event on such a channel
has been processed, which of course is not what one expects.

Solution:

I have no concrete proposal as I am not too familiar with the
internals of the Tcl channel code. However, it might help to not call
Tcl_UnregisterChannel in Tcl_UnregisterChannel and to decrement the
reference counter directly. (I did not test this and there might be
more elegant ways.)

Question:

Do you agree that this is a bug? If yes, when can we expect the next
official patch which corrects the problem? (I have to decide whether I
have to rewrite my code to work around the problem or if I can expect
a fixed version of Tcl and TclPro soon. Thanks,

Juergen

Juergen Schoenwaelder schoenw@ibr.cs.tu-bs.de http://www.cs.tu-bs.de/~schoenw
Technical University Braunschweig, Dept. Operating Systems & Computer Networks
Bueltenweg 74/75, 38106 Braunschweig, Germany. (Tel. +49 531 / 391 3289)

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.