You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ python2.5
Python 2.5.2 (r252:60911, Jun 16 2008, 15:20:47)
[GCC 3.3.5 (propolice)] on openbsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> defcomplete(text, state):
... print'complete %r%d'% (text, state)
... if text =='i'and state ==0:
... return'import'
... else:
... returnNone
...
>>> import readline; readline.parse_and_bind("tab: complete")
>>> readline.set_completer(complete)
>>> i<TAB># <TAB> is press the tab key
complete 'i' 0
complete 'i' 1
Segmentation fault (core dumped)
The problem is that Python is using a function present in libreadline
but not declared in readline/readline.h: completion_matches. Instead of
using rl_completion_matches.
Therefor the return type of completion_matches was an int which is
32bits on amd64 but the function was supposed to returns a pointer which
is 64 bits. So when the pointer had a "high" value, it was truncated.
The problem is fixed by adding libcurses to AC_CHECK_LIB when checking
for functions in libreadline since libreadline depends on curses. This
makes Python use the correct functions declared on readline.h with a
correct return type.
Patch is attached.
(Others versions of Python should also be affected)
I just compiled the latest version of trunk. The problem seems to be
fixed. And according to config.log & nm, readline.so is linked with the
right function.
Activity
henryprecheur commentedon Aug 22, 2008
$ python2.5 Python 2.5.2 (r252:60911, Jun 16 2008, 15:20:47) [GCC 3.3.5 (propolice)] on openbsd4 Type "help", "copyright", "credits" or "license" for more information. >>> def complete(text, state): ... print 'complete %r %d' % (text, state) ... if text == 'i' and state == 0: ... return 'import' ... else: ... return None ... >>> import readline; readline.parse_and_bind("tab: complete") >>> readline.set_completer(complete) >>> i<TAB> # <TAB> is press the tab key complete 'i' 0 complete 'i' 1 Segmentation fault (core dumped) The problem is that Python is using a function present in libreadline but not declared in readline/readline.h: completion_matches. Instead of using rl_completion_matches. Therefor the return type of completion_matches was an int which is 32bits on amd64 but the function was supposed to returns a pointer which is 64 bits. So when the pointer had a "high" value, it was truncated. The problem is fixed by adding libcurses to AC_CHECK_LIB when checking for functions in libreadline since libreadline depends on curses. This makes Python use the correct functions declared on readline.h with a correct return type.Patch is attached.
(Others versions of Python should also be affected)
henryprecheur commentedon Aug 22, 2008
Looks like this patch should also be applied to python 2.6 & 3.
I did not tested but the patch is trivial enough to be applied without
too much fear of breaking something ;)
gpshead commentedon Sep 3, 2008
committed to trunk (2.6) in r66179. This should be back ported to
release25-maint and automagically merged into py3k.
can someone with OpenBSD confirm that this has indeed fixed the problem?
if so i'll do the 25 backport and mark it as closed instead of pending.
henryprecheur commentedon Sep 4, 2008
I just compiled the latest version of trunk. The problem seems to be
fixed. And according to config.log & nm, readline.so is linked with the
right function.
rpetrov commentedon Sep 4, 2008
may bpo-1204 is more general
gpshead commentedon Sep 6, 2008
true, bpo-1204 is more general. i'll leave this in but it can be
removed once the better general fix is in with 1204. i won't backport
this one.