[2.7] bpo-29854: Fix segfault in call_readline()#2637
Conversation
If history-length is set in .inputrc, and the history file is double the history size (or more), history_get(N) returns NULL, and python segfaults. Fix that by checking for NULL return value. It seems that the root cause is incorrect handling of bigger history in readline, but Python should not segfault even if readline returns unexpected value. This issue affects only GNU readline. When using libedit emulation system history size option does not work. This is a backport of the actual fix from master without the test, since the test depends on new run_pty() helper which is not available in 2.7.
That's a bit weird. I think it should build fine since all of the usages of rl_resize_terminal covered by the HAVE_RL_RESIZE_TERMINAL check. See this for an example. Could you post a little bit more information here? |
|
The issue is this check in setup.py: if host_platform == 'darwin':
os_release = int(os.uname()[2].split('.')[0])
dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
if (dep_target and
(tuple(int(n) for n in dep_target.split('.')[0:2])
< (10, 5) ) ):
os_release = 8
if os_release < 9:
# MacOSX 10.4 has a broken readline. Don't try to build
# the readline module unless the user has installed a fixed
# readline package
if find_file('readline/rlconf.h', inc_dirs, []) is None:
do_readline = False```When configuring 2.7, we MACOSX_DEPLOYMENT_TARGET is "10.4", and readline is MACOSX_DEPLOYMENT_TARGET Identifies the earliest OS X version the product is to This is also reproducible on travis OS X build, see: I think we need to open a separate issue for this, this is not related to this fix, since readline |
vstinner
left a comment
There was a problem hiding this comment.
The backport lacks the test_readline change, and please use better PR title.
Agreed, could you create a new issue on bugs.p.o? |
|
@Haypo, the title is hopefully better now. |
|
@Haypo, the test depends on run_pty(), not available in 2.7, and it depends on the selectors module. Too much work for one test. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM.
It's ok to not backport the test.
|
@berkerpeksag: What do you think? |
Agreed. I just merged the PR. Thank you all! |
Tested on Fedora 25, FreeBSD 10.3, FreeBSD 11.0.
On OS X 10.11.6, python 2.7 builds without readline since configure fail to find rl_resize_terminal in -lreadline, so I could not test it.
@berkerpeksag, @Haypo please review.
(cherry picked from commit fae8f4a)