[Pkg-tcltk-devel] Bug#826741: tcl nonblocking "gets" has serious spinning bug

Ian Jackson ijackson at chiark.greenend.org.uk
Wed Jun 8 13:22:10 UTC 2016


Package: libtcl8.6
Version: 8.6.2+dfsg-2+iwj1
Tags: + fixed-upstream
Control: fixed -1 8.6.5+dfsg-2

Running the attached script demonstrates that gets(3tcl) has a serious
bug in jessie's tcl.  See attached transcript.

I used gdb on tcl8.6 and the bug seems to be that in TclGetsObjBinary,
if CHANNEL_BLOCKED is set on entry, and the buffer does not already
contain a newline, TclGetsObjBinary doesn't attempt to read from the
underlying fd.  It simply indicates "nothing ready now".

The fd remains readable, so the fileevent re-triggers.

In a real application this means that the event loop will spin.  It
will not only use excessive CPU use, but this spinning can prevent
other events being processed, resulting in nonfunctional applications.

I found this bug report in the upstream bug tracker which seems
relevant:
  https://core.tcl.tk/tcl/tktview/10dc6daa375d45051a3c
Particularly, the comment "anonymous added on 2014-10-17 08:43:43"
contains a code change which looks to me like it would fix the
problem (although this code is very tangled).

A good approach for Debian might be to update stable's tcl8.6 to a
more recent upstream stable branch.  stretch's tcl8.6 does not have
the bug, and AFAICT is very similar to upstream 8.6.5.

Thanks,
Ian.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test-script
URL: <http://lists.alioth.debian.org/pipermail/pkg-tcltk-devel/attachments/20160608/9e425067/attachment.ksh>
-------------- next part --------------


-- 
Ian Jackson <ijackson at chiark.greenend.org.uk>   These opinions are my own.

If I emailed you from an address @fyvzl.net or @evade.org.uk, that is
a private address which bypasses my fierce spamfilter.


More information about the Pkg-tcltk-devel mailing list