This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tkinter.createfilehandler dumps core
Type: Stage:
Components: Tkinter Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: loewis, nnorwitz, romberg
Priority: high Keywords:

Created on 2003-02-24 18:54 by romberg, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Messages (5)
msg14798 - (view) Author: Mike Romberg (romberg) * Date: 2003-02-24 18:54
  This small example probably uses an invalid
mask and the filedescriptor for a dummy file.  But
I'm seeing this core dump even when using
a correct mask and sockets.  This is with 2.3a2.

>>> import Tkinter
>>> tk = Tkinter.Tk()
>>> fp = open('foo', 'w')
>>> def foo():
...     pass
... 
>>> Tkinter._tkinter.createfilehandler(fp.fileno(), 0, foo)
Segmentation fault (core dumped)


  Here is the traceback:

#0  Tkapp_CreateFileHandler (self=0x0, args=0x1) at
Modules/_tkinter.c:2205
#1  0x080f279a in PyCFunction_Call (func=0x0,
arg=0x40730a68, kw=0x0)
    at Objects/methodobject.c:108
#2  0x080a73cd in call_function (pp_stack=0xbffff2ec,
oparg=1)
    at Python/ceval.c:3285
#3  0x080a58ed in eval_frame (f=0x815700c) at
Python/ceval.c:2041
#4  0x080a630c in PyEval_EvalCodeEx (co=0x40569160,
globals=0x0, locals=0x1, 
    args=0x815700c, argcount=0, kws=0x0, kwcount=0,
defs=0x0, defcount=0, 
    closure=0x0) at Python/ceval.c:2588
#5  0x080a8af7 in PyEval_EvalCode (co=0x1, globals=0x1,
locals=0x1)
    at Python/ceval.c:535
#6  0x080cf25b in run_node (n=0x4015f4e8, 
    filename=0x1 <Address 0x1 out of bounds>,
globals=0x1, locals=0x1, 
    flags=0x1) at Python/pythonrun.c:1105
#7  0x080ce7ae in PyRun_InteractiveOneFlags (fp=0x1, 
    filename=0x80f530a "<stdin>", flags=0xbffff4d8) at
Python/pythonrun.c:609
#8  0x080ce5a3 in PyRun_InteractiveLoopFlags
(fp=0x421271c0, 
    filename=0x80f530a "<stdin>", flags=0x40569160) at
Python/pythonrun.c:542
#9  0x080cfae2 in PyRun_AnyFileExFlags (fp=0x421271c0, 
    filename=0x80f530a "<stdin>", closeit=0,
flags=0xbffff4d8)
    at Python/pythonrun.c:505
#10 0x08054909 in Py_Main (argc=0, argv=0xbffff544) at
Modules/main.c:446
#11 0x0805448b in main (argc=1, argv=0x1) at
Modules/python.c:23
#12 0x420158d4 in __libc_start_main () from
/lib/i686/libc.so.6
msg14799 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-02-26 03:10
Logged In: YES 
user_id=33168

Confirmed the core dump on Linux with Tk 8.3.  Hopefully
Martin will be back soon.  If not I'll try to take a look.
msg14800 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-03-01 22:46
Logged In: YES 
user_id=33168

The problem is that CHECK_TCL_APPARTMENT is called in
Tkapp_CreateFileHandler() and Tkapp_DeleteFileHandler(). 
The CHECK_TCL_APPARTMENT macro uses self which is NULL when
called through the module.  Checking if (self == NULL)
before calling CHECK_TCL_APPARTMENT would prevent the crash,
but I'm not certain this is correct.

As a workaround, you should be able to access create/delete
filehandler through the instance:

   w.tk.createfilehandler(...)

instead of Tkinter.createfilehandler(...).
msg14801 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-03-03 10:54
Logged In: YES 
user_id=21627

This is now fixed in _tkinter.c 1.150 (also for
createtimerhandler). In threaded Tcl, createfilehandler
can't really work if invoked from a different thread, so you
will have to use a non-threaded Tcl to continue to use
_tkinter.createfilehandler.
msg14802 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-03-03 21:28
Logged In: YES 
user_id=33168

Also fixed for deletefilehandler.
Checked in as:
 * Modules/_tkinter.c 1.151
 * Misc/NEWS 1.688
History
Date User Action Args
2022-04-10 16:07:05adminsetgithub: 38040
2003-02-24 18:54:11rombergcreate