python segfault for-loop + print

Bug #546054 reported by Erik Lovlie
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IPython
Invalid
Undecided
Unassigned

Bug Description

Python segfaults for a fairly simple python for-loop. I realize that a segfault shouldn't happen anyway, and that it likely means there is a bug in python, but I am posting it here since I was running IPython. I also am not sure that what I am typing makes sense, as I don't know python much at all.

Steps to reproduce:
1. start ipython
2. type:
for i in range: [enter]
print 42 [enter]

Observe: segfault (backtrace attached below). Happens every time.

Version info:

IPython 0.10
Python 2.5.4 (r254:67916, Oct 1 2009, 01:51:32)
Linux 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux

Backtrace:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 182894237888 (LWP 25515)]
0x00000031e32691a5 in free () from /lib64/tls/libc.so.6
(gdb) bt
#0 0x00000031e32691a5 in free () from /lib64/tls/libc.so.6
#1 0x0000002a96d58d6a in py_remove_history (self=0x20, args=0x20) at /arm/scratch/camdan01/depot/python/python/2.5.4/rhe4-x86_64/Modules/readline.c:318
#2 0x000000000048afa2 in PyEval_EvalFrameEx (f=0x92a8d0, throwflag=9611920) at Python/ceval.c:3612
#3 0x000000000048c861 in PyEval_EvalCodeEx (co=0x2a974c1a08, globals=0x935bf0, locals=0x20, args=0x91e618, argcount=3, kws=0x91e630, kwcount=0, defs=0x2a97721410, defcount=2, closure=0x0)
    at Python/ceval.c:2875
#4 0x000000000048abdd in PyEval_EvalFrameEx (f=0x91e470, throwflag=-1754119512) at Python/ceval.c:3707
#5 0x000000000048c861 in PyEval_EvalCodeEx (co=0x2a974c1288, globals=0x935bf0, locals=0x20, args=0x928298, argcount=2, kws=0x9282a8, kwcount=0, defs=0x2a97717de8, defcount=1, closure=0x0)
    at Python/ceval.c:2875
#6 0x000000000048abdd in PyEval_EvalFrameEx (f=0x928110, throwflag=-1754121208) at Python/ceval.c:3707
#7 0x000000000048c861 in PyEval_EvalCodeEx (co=0x2a974b9f30, globals=0x935bf0, locals=0x20, args=0x91c790, argcount=2, kws=0x91c7a0, kwcount=0, defs=0x2a97717da8, defcount=1, closure=0x0)
    at Python/ceval.c:2875
#8 0x000000000048abdd in PyEval_EvalFrameEx (f=0x91c600, throwflag=-1754121928) at Python/ceval.c:3707
#9 0x000000000048c861 in PyEval_EvalCodeEx (co=0x2a95655a80, globals=0x935bf0, locals=0x20, args=0x2a97133930, argcount=1, kws=0x6d19e0, kwcount=0, defs=0x2a97133920, defcount=2, closure=0x0)
    at Python/ceval.c:2875
#10 0x000000000048abdd in PyEval_EvalFrameEx (f=0x6d1860, throwflag=-1754095536) at Python/ceval.c:3707
#11 0x000000000048c861 in PyEval_EvalCodeEx (co=0x2a955ed5d0, globals=0x935bf0, locals=0x20, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:2875
#12 0x000000000048c9d2 in PyEval_EvalCode (co=0x20, globals=0x935bf0, locals=0x20) at Python/ceval.c:514
#13 0x00000000004af283 in PyRun_FileExFlags (fp=0x65e010, filename=0x7fbfffc60b "/home/erilov01/python/ipython-0.10/ipython.py", start=0, globals=0x681530, locals=0x681530, closeit=1,
    flags=0x7fbfffc0dc) at Python/pythonrun.c:1273
#14 0x00000000004b011f in PyRun_SimpleFileExFlags (fp=0x65e010, filename=0x7fbfffc60b "/home/erilov01/python/ipython-0.10/ipython.py", closeit=1, flags=0x7fbfffc0dc) at Python/pythonrun.c:879
#15 0x0000000000412061 in Py_Main (argc=0, argv=0x0) at Modules/main.c:532
#16 0x00000031e321c3fb in __libc_start_main () from /lib64/tls/libc.so.6
#17 0x000000000041172a in _start ()

(gdb) up
#1 0x0000002a96d58d6a in py_remove_history (self=0x20, args=0x20) at /arm/scratch/camdan01/depot/python/python/2.5.4/rhe4-x86_64/Modules/readline.c:318
318 /arm/scratch/camdan01/depot/python/python/2.5.4/rhe4-x86_64/Modules/readline.c: No such file or directory.
 in /arm/scratch/camdan01/depot/python/python/2.5.4/rhe4-x86_64/Modules/readline.c
(gdb) info locals
entry_number = 16
entry = (HIST_ENTRY *) 0x92aec0

Revision history for this message
Erik Lovlie (eriklovlie) wrote :

Ehm, the "script" I am trying to run should be:

for i in range(10): [enter]
    print 42 [enter]

Revision history for this message
Fernando Perez (fdo.perez) wrote :

I don't see the problem on my build of Python:

amirbar[IPython]> python2.5 `which ipython`
Python 2.5.4 (r254:67916, Jan 20 2010, 21:44:03)
Type "copyright", "credits" or "license" for more information.

IPython 0.11.alpha1.bzr.r1223 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: for i in range:
   ...: print 43
   ...:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)

/home/fperez/ipython/repo/trunk-lp/IPython/<ipython console> in <module>()

TypeError: 'builtin_function_or_method' object is not iterable

But in any case, this is a Python bug, not an ipython one. The crash is coming from inside Python itself, nothing done by IPython here plays a role (other than having imported readline, which appears in the traceback, but still it's a Python bug).

You may want to report it to Python itself, closing here.

Changed in ipython:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.