Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tkinter.createfilehandler dumps core #38040

Closed
romberg mannequin opened this issue Feb 24, 2003 · 5 comments
Closed

tkinter.createfilehandler dumps core #38040

romberg mannequin opened this issue Feb 24, 2003 · 5 comments
Assignees

Comments

@romberg
Copy link
Mannequin

romberg mannequin commented Feb 24, 2003

BPO 692416
Nosy @loewis

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/loewis'
closed_at = <Date 2003-03-03.21:28:01.000>
created_at = <Date 2003-02-24.18:54:11.000>
labels = ['expert-tkinter']
title = 'tkinter.createfilehandler dumps core'
updated_at = <Date 2003-03-03.21:28:01.000>
user = 'https://bugs.python.org/romberg'

bugs.python.org fields:

activity = <Date 2003-03-03.21:28:01.000>
actor = 'nnorwitz'
assignee = 'loewis'
closed = True
closed_date = None
closer = None
components = ['Tkinter']
creation = <Date 2003-02-24.18:54:11.000>
creator = 'romberg'
dependencies = []
files = []
hgrepos = []
issue_num = 692416
keywords = []
message_count = 5.0
messages = ['14798', '14799', '14800', '14801', '14802']
nosy_count = 3.0
nosy_names = ['loewis', 'nnorwitz', 'romberg']
pr_nums = []
priority = 'high'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue692416'
versions = ['Python 2.3']

@romberg
Copy link
Mannequin Author

romberg mannequin commented Feb 24, 2003

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

@romberg romberg mannequin closed this as completed Feb 24, 2003
@romberg romberg mannequin assigned loewis Feb 24, 2003
@romberg romberg mannequin added the topic-tkinter label Feb 24, 2003
@romberg romberg mannequin closed this as completed Feb 24, 2003
@romberg romberg mannequin assigned loewis Feb 24, 2003
@romberg romberg mannequin added the topic-tkinter label Feb 24, 2003
@nnorwitz
Copy link
Mannequin

nnorwitz mannequin commented Feb 26, 2003

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.

@nnorwitz
Copy link
Mannequin

nnorwitz mannequin commented Mar 1, 2003

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(...).

@loewis
Copy link
Mannequin

loewis mannequin commented Mar 3, 2003

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.

@nnorwitz
Copy link
Mannequin

nnorwitz mannequin commented Mar 3, 2003

Logged In: YES
user_id=33168

Also fixed for deletefilehandler.
Checked in as:

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants