homepage

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: python readline module crashing on NULL access
Type: crash Stage: resolved
Components: Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Make libedit support more generic; port readline / libedit to FreeBSD
View: 13501
Assigned To: Nosy List: Arfrever, benjamin.peterson, donmez, koobs, martin.panter, tfiala, vstinner
Priority: normal Keywords: patch

Created on 2014年02月15日 00:12 by tfiala, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python_2.7.6_module_readline_null.diff tfiala, 2014年02月15日 00:12 Patch to guard against NULL dereference in Modules/readline.c
python_2.7.6_module_readline_null_02.diff tfiala, 2014年02月18日 19:01 Revised patch - removes extra call to history_get()
Messages (6)
msg211252 - (view) Author: Todd Fiala (tfiala) Date: 2014年02月15日 00:12
Hi all,
In working on the LLVM/LLDB project, I've been hitting a bug in the
embedded interpreter that causes a NULL dereference in the Python
readline module. There is a call to the history_get() function with an
assumption that it returns a non-NULL value. This is not guaranteed to
be true of the history_get function, and causes the readline module to
crash when it hits this condition.
I'm attaching a patch to the Python 2.7.6 source code that addresses
this issue. It adds an explicit NULL test of the history_get() return
value before accessing it.
This issue was discovered in top of tree LLDB (LLVM.org debugger project). See here for details:
http://llvm.org/bugs/show_bug.cgi?id=18841 
msg211538 - (view) Author: Todd Fiala (tfiala) Date: 2014年02月18日 19:01
Cleaned up the proposed patch a bit. Moves HIST_ENTRY* into a tighter block and removes the second call to history_get() since the value is already stashed in the NULL-checked local.
msg226817 - (view) Author: Ismail Donmez (donmez) * Date: 2014年09月12日 12:25
Can we please get a review on this?
msg226860 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014年09月14日 00:44
Why does _py_get_history_length return a positive value if there's no line available?
msg269000 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016年06月21日 14:03
I think an answer to Benjamin’s question is necessary to move this forward. The code already checks the index before calling history_get(). How do you manage to get null pointers returned for every history item?
In the LLVM bug thread, I noticed "libedit" a.k.a. Editline mentioned a few times. Are you sure Python is using Gnu Readline, or is it somehow hooking into Editline? Python only really supports Editline on Apple, not Linux (see Issue 13501 for expanding that support).
msg290042 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017年03月23日 11:22
Closing in favour of Issue 13501, since the report was apparently about using a non-Apple Editline rather than Gnu Readline. However see also Issue 29854, where the same symptom is seen with Gnu Readline, and it will probably get the same fix.
History
Date User Action Args
2022年04月11日 14:57:58adminsetgithub: 64830
2017年03月23日 11:24:13martin.pantersetsuperseder: Make libedit support more generic; port readline / libedit to FreeBSD
2017年03月23日 11:23:15martin.pantersetstatus: open -> closed
resolution: duplicate
stage: patch review -> resolved
2017年03月23日 11:22:51martin.pantersetstatus: pending -> open

messages: + msg290042
2016年06月21日 14:03:34martin.pantersetstatus: open -> pending
nosy: + martin.panter
messages: + msg269000

2014年09月14日 00:58:40Arfreversetnosy: + Arfrever
2014年09月14日 00:44:50benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg226860
2014年09月12日 13:10:50vstinnersetnosy: + vstinner
2014年09月12日 12:25:33donmezsetnosy: + donmez
messages: + msg226817
2014年02月19日 12:51:57pitrousetstage: patch review
versions: + Python 3.3, Python 3.4
2014年02月18日 19:01:54tfialasetfiles: + python_2.7.6_module_readline_null_02.diff

messages: + msg211538
2014年02月15日 02:33:49koobssetnosy: + koobs
2014年02月15日 00:13:52tfialasettype: crash
2014年02月15日 00:12:11tfialacreate

AltStyle によって変換されたページ (->オリジナル) /