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: Segfault in REPL after pressing "r" and PgUp twice (on Mageia Linux x86-64 6)
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 3.4
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, martin.panter, r.david.murray, shlomif
Priority: normal Keywords:

Created on 2015-08-29 16:01 by shlomif, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
inputrc shlomif, 2015-08-29 16:01
_inputrc shlomif, 2015-08-29 17:20
py3.strace.xz shlomif, 2015-08-29 19:26
py3.gdb-bt.txt shlomif, 2015-08-29 20:36
Messages (13)
msg249322 - (view) Author: Shlomi Fish (shlomif) * Date: 2015-08-29 16:01
After I run python3 (to run the REPL) and type "r" and then PgUp twice, I get a segfault. I'm on Mageia Linux x86-64 6 , but recall a similar problem happening before:

shlomif@telaviv1:~$ python3
Python 3.4.3 (default, Aug 13 2015, 21:40:54) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> rSegmentation fault
shlomif@telaviv1:~$ python3^C

I'm attaching the /etc/inputrc.
msg249326 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-08-29 17:09
What makes you think this is a bug in Python?  Can you reduce the inputrc to the minimum that reproduces the problem?
msg249327 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-08-29 17:13
Sorry, should have been clearer "a bug in python as opposed to one in Mageia's readline".
msg249328 - (view) Author: Shlomi Fish (shlomif) * Date: 2015-08-29 17:20
I'm attaching here the reduced, minimal, inputrc. I think it's a bug in Python because it doesn't happen with any other program that uses readline (bash, perl -d, etc.) that I checked. I'll check with a vanilla readline compiled from source from the GNU site , though.
msg249330 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-08-29 17:48
I can't reproduce it on my Gentoo box using 3.4 tip.
msg249331 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2015-08-29 18:44
Maybe the problem is using escape characters (0x1b) instead of \e. Try using the following:

"\e[5~": history-search-backward

FWIW, your inputrc doesn't crash my system (64-bit Linux, readline 6.3 and Python 3.4).
msg249332 - (view) Author: Shlomi Fish (shlomif) * Date: 2015-08-29 19:26
Hi all!

Thanks for the investigation.

I have now built readline-6.3 from source using:

./configure --prefix="$HOME/apps/readline-TO_DEL" --with-curses=yes --enable-multibyte

and installed it. Then I built python 3.4.3 from source against it by setting LIBRARY_PATH/CPATH/etc. and by this patch to setup.py:

        if True: # if cross_compiling:
            self.add_gcc_paths()

After I built it and ran it, it still segfaults after I type "r" and press PgUp twice. I've attached the strace output (compressed with xz).
msg249334 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2015-08-29 20:24
A gdb backtrace may be of more help than strace.
msg249335 - (view) Author: Shlomi Fish (shlomif) * Date: 2015-08-29 20:36
gdb by full attached.
msg249343 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-08-29 22:35
Well it looks like you’ve identified that PgUp triggers a history search. Perhaps it would be good to look at your /home/shlomif/.python_history file, assuming there is nothing sensitive in there. The strace output only indicates it is 411 bytes and gives the first one-and-a-half lines. My guess is there is something funny about a line beginning with “r”, or a nearby line.

But it still sounds like a Readline bug instead of a Python bug. If you clear or remove the history file, does the bug go away? Maybe you can replace the equivalent ~/.bash_history or Perl history file to see if it triggers a crash there.
msg249344 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-08-29 23:08
According to the GDB backtrace, _rl_kscxt is a null pointer at <https://github.com/Distrotech/readline/blob/readline-6.3/callback.c#L188>, while the _rl_dispatch_callback() function doesn’t handle null pointers. Maybe you would find the Readline people more knowledgeable about this.
msg249352 - (view) Author: Shlomi Fish (shlomif) * Date: 2015-08-30 06:59
Marting Panter: I'm getting the same problem with a completely empty ~/.python_history file. Moreover, I was able to reproduce a similar bug in gdb. I'll try seeing if I can create a minimal GNU readline-using program here that reproduces it.
msg249353 - (view) Author: Shlomi Fish (shlomif) * Date: 2015-08-30 07:14
Martin: [sorry for misspelling your name] I was now able to reproduce the same problem using rlwrap (see http://utopia.knoware.nl/~hlub/rlwrap/ ). I'll report it to the readline problem.
History
Date User Action Args
2022-04-11 14:58:20adminsetgithub: 69146
2015-08-30 14:15:07r.david.murraysetstatus: open -> closed
resolution: third party
stage: resolved
2015-08-30 07:14:14shlomifsetmessages: + msg249353
2015-08-30 06:59:21shlomifsetmessages: + msg249352
2015-08-29 23:08:32martin.pantersetmessages: + msg249344
2015-08-29 22:35:30martin.pantersetnosy: + martin.panter
messages: + msg249343
2015-08-29 20:36:49shlomifsetfiles: + py3.gdb-bt.txt

messages: + msg249335
2015-08-29 20:24:52eryksunsetmessages: + msg249334
2015-08-29 19:26:11shlomifsetfiles: + py3.strace.xz

messages: + msg249332
2015-08-29 18:44:05eryksunsetnosy: + eryksun
messages: + msg249331
2015-08-29 17:48:07r.david.murraysetmessages: + msg249330
2015-08-29 17:20:36shlomifsetfiles: + _inputrc

messages: + msg249328
2015-08-29 17:13:39r.david.murraysetmessages: + msg249327
2015-08-29 17:09:49r.david.murraysetnosy: + r.david.murray
messages: + msg249326
2015-08-29 16:01:33shlomifcreate