gnovak - 2007-01-08

I'm interested in using the GDL python module to call IDL code
from Python.

When "enough" of readline has been activated, I get a seg fault
with the backtrace listed below when trying to run the example
from Python.txt:

import GDL
GDL.function("sin", (1,))

One way to initialize enough of readline is to use IPython, an
enhanced interactive Python shell (this is how I found the bug).
Another way is to follow the instructions from IPython's
author (no IPython required) listed below.

Seems like this may be a readline bug, so I'm also posting there.
I'm posting this to see if people have any ideas about
workarounds/fixes.

Thanks!
Greg

----------------------------------------------------------------------
Message from Fernando Perez:

Here's how to crash plain python (at least it
works reliably on my ubuntu box).  Paste this into an interactive
session (don't try to execfile, you have to paste it as if you had
typed it interactively so readline has to work):

import os
import readline

''' Some gibberish here is needed that's long enough to trigger the bug.  I'm
not sure how much data is actually required...

12jd lsjlksajsa jfl;ksaj34567890
123asdjf lkasdj flkajs l;kfd4567890
123asdflkasdj fl;saj f;a4567890
12jd lsjlksajsa jfl;ksaj34567890
123asdjf lkasdj flkajs l;kfd4567890
123asdflkasdj fl;saj f;a4567890
12jd lsjlksajsa jfl;ksaj34567890
123asdjf lkasdj flkajs l;kfd4567890
123asdflkasdj fl;saj f;a4567890
'''

try:
   __histfile = os.path.join(os.environ['HOME'],'.python-history')
   readline.read_history_file(__histfile)
except IOError:
   pass  # History file doesn't exist yet.

# This will now cause a crash:

import GDL
print GDL.function("sin",(1,))

# EOF

----------------------------------------------------------------------
Backtrace:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x00556304 in call_readline (sys_stdin=0x699b20, sys_stdout=0x697f40, prompt=0x5
56c70 "") at /Volumes/Panther/sw.build/python24-2.4.2-1004/Python-2.4.2/Modules/
readline.c:885
885     /Volumes/Panther/sw.build/python24-2.4.2-1004/Python-2.4.2/Modules/readl
ine.c: No such file or directory.
        in /Volumes/Panther/sw.build/python24-2.4.2-1004/Python-2.4.2/Modules/re
adline.c
(gdb) bt
#0  0x00556304 in call_readline (sys_stdin=0x699b20, sys_stdout=0x697f40, prompt=0x556c70 "") at /Volumes/Panther/sw.build/python24-2.4.2-1004/Python-2.4.2/Modules/readline.c:885
#1  0x000bc0bc in PyOS_Readline (sys_stdin=0xa0001b9c, sys_stdout=0xa0001bf4, prompt=0x5b36d6c "\n\001\033[0;34m\002In [\001\033[1;34m\0022\001\033[0;34m\002]: \001\033[0m\002") at Parser/myreadline.c:208
#2  0x000a4cac in builtin_raw_input (self=0x0, args=0xa0001b9c) at Python/bltinmodule.c:1631
#3  0x000911b8 in PyEval_EvalFrame (f=0x1904010) at Python/ceval.c:3558
#4  0x00093480 in PyEval_EvalCodeEx (co=0x78a760, globals=0x14, locals=0x0, args=0x18fdd74, argcount=3, kws=0x18fdd80, kwcount=0, defs=0x11fb44c, defcount=2, closure=0x0) at Python/ceval.c:2736
#5  0x000913d4 in PyEval_EvalFrame (f=0x18fdc10) at Python/ceval.c:3651
#6  0x00093480 in PyEval_EvalCodeEx (co=0x78a3e0, globals=0x14, locals=0x0, args=0x1801d64, argcount=2, kws=0x1801d6c, kwcount=0, defs=0x11fa13c, defcount=1, closure=0x0) at Python/ceval.c:2736
#7  0x000913d4 in PyEval_EvalFrame (f=0x1801c10) at Python/ceval.c:3651
#8  0x00093480 in PyEval_EvalCodeEx (co=0x78a2a0, globals=0x14, locals=0x0, args=0x627028, argcount=2, kws=0x627030, kwcount=0, defs=0x11fa11c, defcount=1, closure=0x0) at Python/ceval.c:2736
#9  0x000913d4 in PyEval_EvalFrame (f=0x626ed0) at Python/ceval.c:3651
#10 0x00093480 in PyEval_EvalCodeEx (co=0x754520, globals=0x14, locals=0x0, args=0x627028, argcount=1, kws=0x601390, kwcount=0, defs=0x11fb4ec, defcount=2, closure=0x0) at Python/ceval.c:2736
#11 0x000913d4 in PyEval_EvalFrame (f=0x601240) at Python/ceval.c:3651
#12 0x00093480 in PyEval_EvalCodeEx (co=0x37b820, globals=0x14, locals=0x0, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:2736
#13 0x00093610 in PyEval_EvalCode (co=0x0, globals=0x14, locals=0x14800000) at Python/ceval.c:484
#14 0x0000db54 in PyRun_FileExFlags (fp=0xa000db34, filename=0xbffff33e "/sw/bin/ipython2.4", start=20, globals=0x34ba50, locals=0x34ba50, closeit=1, flags=0x37b820) at Python/pythonrun.c:1265
#15 0x0000defc in PyRun_SimpleFileExFlags (fp=0xa000db34, filename=0xbffff33e "/sw/bin/ipython2.4", closeit=1, flags=0xbffff14c) at Python/pythonrun.c:860
#16 0x000067e4 in Py_Main (argc=-1073745588, argv=0x80000000) at Modules/main.c:484
#17 0x00001e48 in _start (argc=2, argv=0xbffff254, envp=0xbffff260) at /SourceCache/Csu/Csu-58/crt.c:272
#18 0x00001cf0 in start ()