[issue1087741] subclassable mmap
Ralf Schmitt
report at bugs.python.org
Tue Jan 22 14:25:30 CET 2008
Ralf Schmitt added the comment:
sorry, I somehow managed to introduce a segfault:
~/pydev/trunk/ cat t.py
ralf at red ok
from mmap import mmap
class anon_mmap(mmap):
def __new__(klass, *args, **kwargs):
res = mmap.__new__(klass, -1, *args, **kwargs)
print "NEW:", res
return res
anon_mmap(4096)
~/pydev/trunk/ ./python t.py
ralf at red ok
NEW: <__main__.anon_mmap object at 0x866b10>
Debug memory block at address p=0x866b10:
18374686479671623679 bytes originally requested
The 8 pad bytes at p-8 are not all FORBIDDENBYTE (0xfb):
at p-8: 0xcb *** OUCH
at p-7: 0xcb *** OUCH
at p-6: 0xcb *** OUCH
at p-5: 0xcb *** OUCH
at p-4: 0xcb *** OUCH
at p-3: 0xcb *** OUCH
at p-2: 0xcb *** OUCH
at p-1: 0xcb *** OUCH
Because memory is corrupted at the start, the count of bytes requested
may be bogus, and checking the trailing pad bytes may segfault.
The 8 pad bytes at tail=0xff00000000866b0f are zsh: segmentation
fault ./python t.py
The following fixes it for me:
~/pydev/trunk/ cat patch
ralf at red failed 139
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -129,7 +129,7 @@ mmap_object_dealloc(mmap_object *m_obj)
}
#endif /* UNIX */
- PyObject_Del(m_obj);
+ m_obj->ob_type->tp_free((PyObject*)m_obj);
}
static PyObject *
I'll write a test for this issue and will attach a complete patch.
Sorry again.
_____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1087741>
_____________________________________
More information about the Python-bugs-list
mailing list