Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-22
17:19 • Ticket [8aa32fadb3] Tcl_CreateFileHandler crash status still Closed with 3 o... artifact: e2b9d459c0 user: serhiy.storchaka
2026-09-20
10:46 • Closed ticket [8aa32fadb3]. artifact: 0501051dde user: serhiy.storchaka
2014-01-05
16:31 • Pending ticket [8aa32fadb3]. artifact: 774cd89763 user: dkf
2013-12-04
09:05 • Ticket [8aa32fadb3]: 5 changes artifact: 5c431bb007 user: dkf
2013-12-03
21:56 • Ticket [8aa32fadb3]: 3 changes artifact: 065f99a9cd user: anonymous
17:22 • New ticket [8aa32fadb3]. artifact: d2c79b3a84 user: anonymous

Tcl_CreateFileHandler crash

Closed / Duplicate8aa32fadb361b076d66aa37d44b6eaa43eca078dCreated 13 years agoUpdated 42 days ago
Descriptionplain2013-12-03 17:22:42
[root@<removed> fuzz]# cat libtcl85.py
#
# Libtcl 8.5 createfilehandler() crash poc
#
# Level was here
#
import _tkinter
def errback(*args, **kw):
        raise ValueError('error')

_tkinter.createfilehandler(674664117164,59.58,errback)
[root@eagle876 fuzz]# gdb --args python libtcl85.py
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/python...(no debugging symbols found)...done.
Missing separate debuginfos, use: debuginfo-install python-2.6.6-37.el6_4.i686 python-2.6.6-37.el6_4.x86_64
(gdb) r
Starting program: /usr/bin/python libtcl85.py
[Thread debugging using libthread_db enabled]
libtcl85.py:8: DeprecationWarning: integer argument expected, got float
  _tkinter.createfilehandler(674664117164,59.58,errback)

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff05879cd in Tcl_CreateFileHandler () from /usr/lib64/libtcl8.5.so
(gdb) q


The second parameter typically contains an int, when provided a float a crash occurs in libtcl8.5.so.
anonymous Ticket [8aa32fadb3]: 3 changes [History diff]2013-12-03 21:56:33
dkf Ticket [8aa32fadb3]: 5 changes [History diff]2013-12-04 09:05:03
dkfhtml2014-01-05 16:31:17

Trying to force a float (double?) into a int will never be a good thing (especially if it is ending up changing the width of the argument on the stack!). That API function is specifically documented as taking an integer second argument; the bug must be in the code that glues Python to Tcl (which should reject or cast a float second argument; I don't care which).

We don't maintain the tkinter package. Not our bug.

serhiy.storchakawiki2026-09-20 10:46:49

The float was converted to 59 by Python (hence the DeprecationWarning); the crash comes from the descriptor: 674664117164 was truncated to a C int (354251692) by Python 2.6, and the select notifier passes any descriptor to FD_SET() without checking it against FD_SETSIZE, so it writes outside the fd_set. The same happens with any descriptor >= FD_SETSIZE (1024 on Linux), valid or not; with 8.6.17 and a fortified glibc: "bit out of range 0 - FD_SETSIZE on fd_set". Python 3 rejects the descriptor and the float mask of this script (OverflowError, TypeError), but createfilehandler(5000, 1, callback) or a real channel with a descriptor >= FD_SETSIZE still aborts. The epoll notifier (default on Linux in 9.x) is not affected.

This is [c6897e6e6a], which has the analysis and a proposed fix (note that rejecting descriptors when channels are created does not protect Tcl_CreateFileHandler() called by an application with its own descriptors).

serhiy.storchaka Ticket [8aa32fadb3]: 3 changes [History diff]2026-10-22 17:19:24
Log in (anonymous is fine) to add a comment.