[issue25259] readline macros can segfault Python

Martin Panter report at bugs.python.org
Tue Jun 21 01:19:46 EDT 2016


Martin Panter added the comment:

I think Victor may be on the right track. Since the macro contains two newlines, a single call to rl_callback_read_char() is going to produce two calls back to the rl_callback_handler_install() handler to receive each line.

I can make the example from the Readline documentation <https://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC43> crash the same way that Python does. First, add a macro to ~/.inputrc, which causes an exclamation mark (!) to enter two lines at once:

"!": "exit\ncrash\n"

Now, typing an exclamation mark will cause the example program (and Python!) to crash.

In the description of rl_callback_read_char() <https://cnswww.cns.cwru.edu/php/chet/readline/readline.html#IDX335>, it says “If the ‘lhandler’ function returns . . .”. That seems to be hinting at using something like setjmp() to avoid the function returning, which might help, but I am not sure.

----------
nosy: +martin.panter

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25259>
_______________________________________


More information about the Python-bugs-list mailing list