Issue 14212: Segfault when using re.finditer over mmap (original) (raw)

Created on 2012-03-06 18:00 by fijall, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
x.py fijall,2012-03-06 18:00
Messages (5)
msg155028 - (view) Author: Maciej Fijalkowski (fijall) * (Python committer) Date: 2012-03-06 18:00
Example to get a segfault attached. Crashes under python3 as well.
msg155033 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2012-03-06 19:09
It segfaults because it attempts to access the buffer of an mmap that has been closed. It would be certainly be more friendly if it checked whether the mmap was still open and, if not, raised an exception instead.
msg155105 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2012-03-07 18:58
In the function "getstring" in _sre.c, the code obtains a pointer to the characters of the buffer and then releases the buffer. There's a comment before the release: /* Release the buffer immediately --- possibly dangerous but doing something else would require some re-factoring */ PyBuffer_Release(&view); What's happening is that after the mmap is closed the pointer is no longer valid.
msg155121 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-07 20:59
New changeset 10a79a33d09b by Benjamin Peterson in branch '3.2': keep the buffer object around while we're using it (closes #14212) http://hg.python.org/cpython/rev/10a79a33d09b New changeset 17dfe24e5107 by Benjamin Peterson in branch 'default': merge 3.2 (#14212) http://hg.python.org/cpython/rev/17dfe24e5107
msg155122 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2012-03-07 21:00
I think 2.7 might be hopeless.
History
Date User Action Args
2022-04-11 14:57:27 admin set github: 58420
2013-08-05 13:08:04 serhiy.storchaka link issue13083 superseder
2012-03-07 21:01:36 benjamin.peterson set status: open -> closedresolution: fixed
2012-03-07 21:00:15 benjamin.peterson set status: closed -> opennosy: + benjamin.petersonmessages: + resolution: fixed -> (no value)stage: resolved ->
2012-03-07 20:59:27 python-dev set status: open -> closednosy: + python-devmessages: + resolution: fixedstage: resolved
2012-03-07 19:23:17 skrah set nosy: + skrah
2012-03-07 19:01:36 alex set nosy: + alex
2012-03-07 18:58:12 mrabarnett set messages: +
2012-03-06 19:09:31 mrabarnett set nosy: + mrabarnettmessages: +
2012-03-06 18:00:15 fijall create