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: Segmentation fault while using Tkinter
Type: Stage:
Components: Tkinter Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: loewis Nosy List: aligrudi, loewis, nnorwitz
Priority: normal Keywords:

Created on 2006-05-01 04:55 by aligrudi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
rope-0.1pre.tar.gz aligrudi, 2006-05-02 05:25 the program which caused the SIGSEGV(see rope/editor.py)
Messages (7)
msg28389 - (view) Author: Ali Gholami Rudi (aligrudi) Date: 2006-05-01 04:55
While using Tkinter I encountere segmentation faults
regularly. I ran my program using gdb using python2.4
and Fedora Core 5 and received:

(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread -1209063760 (LWP 2024)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread -1212232800 (LWP 2027)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1209063760 (LWP 2024)]
0x001519ce in TkUndoSetDepth () from /usr/lib/libtk8.4.so
(gdb) 


I ran the same program using python2.5a2 and again
received:

Starting program: /usr/local/bin/python
~/temp/rope/rope/rope.py
Reading symbols from shared object read from target
memory...done.
Loaded system supplied DSO at 0xa05000
[Thread debugging using libthread_db enabled]
[New Thread -1208899920 (LWP 2415)]
[New Thread -1212068960 (LWP 2418)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208899920 (LWP 2415)]
0x001519ce in TkUndoSetDepth () from /usr/lib/libtk8.4.so
(gdb)


Are these information enough for fixing the problem or
should I send my program?

Thanks
msg28390 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-05-01 06:34
Logged In: YES 
user_id=21627

Please do send your program, or better yet a small test case
that allows to reproduce the problem. It looks like a Tk bug
at first glance, in TkUndoSetDepth.
msg28391 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-05-01 07:25
Logged In: YES 
user_id=33168

If you can send a small test case that would be great. 
Also, can you attach the backtrace (bt command in gdb)?

How did you configure python?  Did you use an
--enable-unicode or --enable-threads?  Did you built Tcl/Tk
or are you using the default version with FC5?

When python starts up, what do you see?  It should be
something like:

Python 2.5a2 (trunk:45831M, Apr 30 2006, 23:27:02) 
[GCC 4.0.0 20041026 (Apple Computer, Inc. build 4061)] on darwin


Also, what does this print:  
    import sys ; print sys.maxunicode
msg28392 - (view) Author: Ali Gholami Rudi (aligrudi) Date: 2006-05-02 05:25
Logged In: YES 
user_id=965314

I don't know when the segmentation fault occurs. So I can't
write
a test case to reproduce it. That is when I work with my
program(which
is attached) after a some time(a few minutes or a few hours)
I receive
SIGSEGV.

I did not compile Tcl/Tk. And I used the default
configuration for
compiling Python2.5a2. The 'import sys; print
sys.maxunicode;' prints
65535 in both Python versions I've used.


Python 2.4.2
------------
Python 2.4.2 (#1, Feb 12 2006, 03:59:46) 
[GCC 4.1.0 20060210 (Red Hat 4.1.0-0.24)] on linux2

<<<gdb output start>>>
GNU gdb Red Hat Linux (6.3.0.0-1.122rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public
License, and you are
welcome to change it and/or distribute copies of it under
certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show
warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...(no
debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) run ~/temp/rope/rope/rope.py 
Starting program: /usr/bin/python2.4 ~/temp/rope/rope/rope.py
Reading symbols from shared object read from target
memory...(no debugging symbols found)...done.
Loaded system supplied DSO at 0x8a8000
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread -1208494416 (LWP 2121)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread -1211663456 (LWP 2124)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208494416 (LWP 2121)]
0x0099e9ce in TkUndoSetDepth () from /usr/lib/libtk8.4.so
(gdb) bt
#0  0x0099e9ce in TkUndoSetDepth () from /usr/lib/libtk8.4.so
#1  0x0099eac9 in TkUndoInsertUndoSeparator () from
/usr/lib/libtk8.4.so
#2  0x009f7208 in TkTextLostSelection () from
/usr/lib/libtk8.4.so
#3  0x0017fc7e in TclInvokeStringCommand () from
/usr/lib/libtcl8.4.so
#4  0x001815e4 in TclEvalObjvInternal () from
/usr/lib/libtcl8.4.so
#5  0x001ae2aa in Tcl_ExprObj () from /usr/lib/libtcl8.4.so
#6  0x001b218c in TclCompEvalObj () from /usr/lib/libtcl8.4.so
#7  0x001df09c in TclObjInterpProc () from /usr/lib/libtcl8.4.so
#8  0x001815e4 in TclEvalObjvInternal () from
/usr/lib/libtcl8.4.so
#9  0x00181b8f in Tcl_EvalEx () from /usr/lib/libtcl8.4.so
#10 0x00181e9c in Tcl_Eval () from /usr/lib/libtcl8.4.so
#11 0x00181f36 in Tcl_GlobalEval () from /usr/lib/libtcl8.4.so
#12 0x0097a9d9 in Tk_BindEvent () from /usr/lib/libtk8.4.so
#13 0x00980414 in TkBindEventProc () from /usr/lib/libtk8.4.so
#14 0x00985cbf in Tk_HandleEvent () from /usr/lib/libtk8.4.so
#15 0x009862db in Tk_HandleEvent () from /usr/lib/libtk8.4.so
#16 0x001d4267 in Tcl_ServiceEvent () from /usr/lib/libtcl8.4.so
#17 0x001d4537 in Tcl_DoOneEvent () from /usr/lib/libtcl8.4.so
#18 0x00114c6c in init_tkinter () from
/usr/lib/python2.4/lib-dynload/_tkinter.so
#19 0x007da92d in PyCFunction_Call () from
/usr/lib/libpython2.4.so.1.0
#20 0x00815646 in PyEval_EvalFrame () from
/usr/lib/libpython2.4.so.1.0
#21 0x008162c6 in PyEval_EvalCodeEx () from
/usr/lib/libpython2.4.so.1.0
#22 0x00814950 in PyEval_EvalFrame () from
/usr/lib/libpython2.4.so.1.0
#23 0x008151d7 in PyEval_EvalFrame () from
/usr/lib/libpython2.4.so.1.0
#24 0x008162c6 in PyEval_EvalCodeEx () from
/usr/lib/libpython2.4.so.1.0
#25 0x00816353 in PyEval_EvalCode () from
/usr/lib/libpython2.4.so.1.0
#26 0x00832f78 in Py_CompileString () from
/usr/lib/libpython2.4.so.1.0
#27 0x00834688 in PyRun_SimpleFileExFlags () from
/usr/lib/libpython2.4.so.1.0
#28 0x00834d6a in PyRun_AnyFileExFlags () from
/usr/lib/libpython2.4.so.1.0
#29 0x0083b45f in Py_Main () from /usr/lib/libpython2.4.so.1.0
#30 0x080485b2 in main ()
(gdb) 
<<<gdb output end>>>



Python 2.5a2
------------
Python 2.5a2 (r25a2:45740, Apr 29 2006, 18:39:09) 
[GCC 4.1.0 20060304 (Red Hat 4.1.0-3)] on linux2

<<<gdb output start>>>
GNU gdb Red Hat Linux (6.3.0.0-1.122rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public
License, and you are
welcome to change it and/or distribute copies of it under
certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show
warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using
host libthread_db library "/lib/libthread_db.so.1".

(gdb) run ~/temp/rope/rope/rope.py 
Starting program: /usr/local/bin/python ~/temp/rope/rope/rope.py
Reading symbols from shared object read from target
memory...done.
Loaded system supplied DSO at 0x4c6000
[Thread debugging using libthread_db enabled]
[New Thread -1208731984 (LWP 2176)]
[New Thread -1211835488 (LWP 2179)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208731984 (LWP 2176)]
0x0099e9ce in TkUndoSetDepth () from /usr/lib/libtk8.4.so
(gdb) bt
#0  0x0099e9ce in TkUndoSetDepth () from /usr/lib/libtk8.4.so
#1  0x0099eac9 in TkUndoInsertUndoSeparator () from
/usr/lib/libtk8.4.so
#2  0x009f75e7 in TkTextLostSelection () from
/usr/lib/libtk8.4.so
#3  0x0013bc7e in TclInvokeStringCommand () from
/usr/lib/libtcl8.4.so
#4  0x0013d5e4 in TclEvalObjvInternal () from
/usr/lib/libtcl8.4.so
#5  0x0013e59b in Tcl_EvalObjv () from /usr/lib/libtcl8.4.so
#6  0x00118606 in Tkapp_Call (_self=0xb71d4640, args=0xb72337d4)
    at /dev/shm/Python-2.5a2/Modules/_tkinter.c:1324
#7  0x080bc0b2 in PyEval_EvalFrameEx (f=0x89c4a0c,
throwflag=0) at Python/ceval.c:3534
#8  0x080bd807 in PyEval_EvalCodeEx (co=0xb7c627e0,
globals=0xb7ed39bc, locals=0x0, 
    args=0x89c48ac, argcount=2, kws=0x89c48b4, kwcount=0,
defs=0x0, defcount=0, closure=0x0)
    at Python/ceval.c:2809
#9  0x080bb884 in PyEval_EvalFrameEx (f=0x89c475c,
throwflag=0) at Python/ceval.c:3630
#10 0x080bcac5 in PyEval_EvalFrameEx (f=0x8a41fd4,
throwflag=0) at Python/ceval.c:3619
#11 0x080bcac5 in PyEval_EvalFrameEx (f=0x87c931c,
throwflag=0) at Python/ceval.c:3619
#12 0x080bcac5 in PyEval_EvalFrameEx (f=0x87b1ee4,
throwflag=0) at Python/ceval.c:3619
#13 0x080bcac5 in PyEval_EvalFrameEx (f=0x89a0a24,
throwflag=0) at Python/ceval.c:3619
#14 0x080bd807 in PyEval_EvalCodeEx (co=0xb7ecff60,
globals=0xb7ed38ac, locals=0x0, 
    args=0xb71e4258, argcount=1, kws=0x0, kwcount=0,
defs=0x0, defcount=0, closure=0xb71e2f8c)
    at Python/ceval.c:2809
#15 0x081044f1 in function_call (func=0xb71a8374,
arg=0xb71e424c, kw=0x0)
    at Objects/funcobject.c:517
#16 0x08059c77 in PyObject_Call (func=0xb71a8374,
arg=0xb71e424c, kw=0x0)
    at Objects/abstract.c:1792
#17 0x080ba663 in PyEval_EvalFrameEx (f=0x87e732c,
throwflag=0) at Python/ceval.c:3814
#18 0x080bd807 in PyEval_EvalCodeEx (co=0xb7ef90a0,
globals=0xb7ed39bc, locals=0x0, 
    args=0xb723e310, argcount=20, kws=0x0, kwcount=0,
defs=0x0, defcount=0, closure=0x0)
    at Python/ceval.c:2809
#19 0x081044f1 in function_call (func=0xb7c76b54,
arg=0xb723e304, kw=0x0)
    at Objects/funcobject.c:517
#20 0x08059c77 in PyObject_Call (func=0xb7c76b54,
arg=0xb723e304, kw=0x0)
    at Objects/abstract.c:1792
#21 0x0805f847 in instancemethod_call (func=0xb71a78ec,
arg=0xb723e304, kw=0x0)
    at Objects/classobject.c:2421
#22 0x08059c77 in PyObject_Call (func=0xb71a78ec,
arg=0xb7f0a9ec, kw=0x0)
    at Objects/abstract.c:1792
#23 0x080b5aac in PyEval_CallObjectWithKeywords
(func=0xb71a78ec, arg=0xb7f0a9ec, kw=0x0)
---Type <return> to continue, or q <return> to quit---
    at Python/ceval.c:3403
#24 0x001171b2 in PythonCmd (clientData=0x8b84960,
interp=0x87a2080, argc=20, argv=0x8cf1f78)
    at /dev/shm/Python-2.5a2/Modules/_tkinter.c:2011
#25 0x0013bc7e in TclInvokeStringCommand () from
/usr/lib/libtcl8.4.so
#26 0x0013d5e4 in TclEvalObjvInternal () from
/usr/lib/libtcl8.4.so
#27 0x0016a2aa in Tcl_ExprObj () from /usr/lib/libtcl8.4.so
#28 0x001674cd in Tcl_ExprObj () from /usr/lib/libtcl8.4.so
#29 0x0013ce63 in Tcl_ExprBooleanObj () from
/usr/lib/libtcl8.4.so
#30 0x0014b072 in Tcl_IfObjCmd () from /usr/lib/libtcl8.4.so
#31 0x0013d5e4 in TclEvalObjvInternal () from
/usr/lib/libtcl8.4.so
#32 0x0013db8f in Tcl_EvalEx () from /usr/lib/libtcl8.4.so
#33 0x0013de9c in Tcl_Eval () from /usr/lib/libtcl8.4.so
#34 0x0013df36 in Tcl_GlobalEval () from /usr/lib/libtcl8.4.so
#35 0x0097a9d9 in Tk_BindEvent () from /usr/lib/libtk8.4.so
#36 0x00980414 in TkBindEventProc () from /usr/lib/libtk8.4.so
#37 0x00985cbf in Tk_HandleEvent () from /usr/lib/libtk8.4.so
#38 0x009862db in Tk_HandleEvent () from /usr/lib/libtk8.4.so
#39 0x00190267 in Tcl_ServiceEvent () from /usr/lib/libtcl8.4.so
#40 0x00190537 in Tcl_DoOneEvent () from /usr/lib/libtcl8.4.so
#41 0x00116eca in Tkapp_MainLoop (_self=0xb71d4640,
args=0xb7ed690c)
    at /dev/shm/Python-2.5a2/Modules/_tkinter.c:2542
#42 0x080bc0b2 in PyEval_EvalFrameEx (f=0x8752afc,
throwflag=0) at Python/ceval.c:3534
#43 0x080bd807 in PyEval_EvalCodeEx (co=0xb7ef1520,
globals=0xb7ed39bc, locals=0x0, 
    args=0x8741154, argcount=1, kws=0x8741158, kwcount=0,
defs=0xb7c74df8, defcount=1, closure=0x0)
    at Python/ceval.c:2809
#44 0x080bb884 in PyEval_EvalFrameEx (f=0x8741004,
throwflag=0) at Python/ceval.c:3630
#45 0x080bcac5 in PyEval_EvalFrameEx (f=0x873d0c4,
throwflag=0) at Python/ceval.c:3619
#46 0x080bd807 in PyEval_EvalCodeEx (co=0xb7ecbba0,
globals=0xb7f20934, locals=0xb7f20934, 
    args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
defcount=0, closure=0x0)
    at Python/ceval.c:2809
#47 0x080bd877 in PyEval_EvalCode (co=0xb7ecbba0,
globals=0xb7f20934, locals=0xb7f20934)
    at Python/ceval.c:491
#48 0x080dbc2e in PyRun_FileExFlags (fp=0x870b008, 
    filename=0xbfa51aae "/home/ali/temp/rope/rope/rope.py",
start=257, globals=0xb7f20934, 
    locals=0xb7f20934, closeit=1, flags=0xbfa51538) at
Python/pythonrun.c:1224
#49 0x080dbed7 in PyRun_SimpleFileExFlags (fp=0x870b008, 
    filename=0xbfa51aae "/home/ali/temp/rope/rope/rope.py",
closeit=1, flags=0xbfa51538)
---Type <return> to continue, or q <return> to quit---
    at Python/pythonrun.c:854
#50 0x08056934 in Py_Main (argc=1, argv=0xbfa51604) at
Modules/main.c:492
#51 0x08055f02 in main (argc=Cannot access memory at address
0x13
) at ./Modules/python.c:23
(gdb) 
<<<gdb output end>>>


The attached program, using which I encounter the above
problem, is 
rope<http://sf.net/project/rope/>. The editor is in
'rope/editor.py' module.
msg28393 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-05-02 06:27
Logged In: YES 
user_id=21627

Apparently, this has something to do with the undo mechanism
of the text widget; I would expect the problem to go away if
you disable undo (text["undo"]=0). Other than that, there is
not much I can tell, from either looking at the source or at
the backtrace.

Most likely, it is some bug in Tcl/Tk. It also could be that
Python is corrupting memory somehow, and that this causes Tk
to crash.

If you want to debug this yourself, compile Tcl/Tk (with,
say, --prefix==/var/tmp). Use --disable-shared
--enable-symbols for both Tcl and Tk, then edit
Modules/Setup to statically link _tkinter into the Python
interpreter. Replace the -ltk8.2 line with an explict
/var/tmp/lib/libtk8.4g.a, to be sure that your version of tk
is used.

Then run it in a debugger, and find out why it crashes. Is
it really crashing inside TkUndoSetDepth? If so, what is the
value of stack? What is the value of maxdepth? What is the
Tcl command being executed (if Tcl_Eval is on the stack, go
up several times, and print the value of its string argument).
msg28394 - (view) Author: Ali Gholami Rudi (aligrudi) Date: 2006-05-20 06:08
Logged In: YES 
user_id=965314

When I complied Tk/Tcl myself the problem was solved. I
think the built rpm that comes with Fedora5 has problems.

Thanks 
msg28395 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-05-20 06:26
Logged In: YES 
user_id=21627

Closing it as "3rd party", then.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43302
2006-05-01 04:55:32aligrudicreate