[issue4358] Segfault in stringobject.c
Amaury Forgeot d'Arc
report at bugs.python.org
Thu Nov 20 00:15:04 CET 2008
Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:
This is difficult: the backtrace only show plain python operations.
Some hints though:
One backtrace shows a memory corruption in the obmalloc data. This may come from a
buffer overrun.
You initially selected ctypes in "Components", does this mean that your program
also use ctypes?
With ctypes it is easy to be caught with a python string converted to a (mutable)
char* pointer.
For example, on Windows:
>>> import ctypes
>>> c = ctypes.CDLL('msvcrt')
>>> a = " "
>>> c.strcpy(a, "X" * 50)
50
>>> a
'XXXX'
... and the crash is not far.
Another case of corruption in obmalloc is to try to allocate python objects while
the GIL is not held. This may happen if you wrote a C function that uses the
Python API, and call this with ctypes.
In any case, I suggest that you build and a use a debug-enabled version of python
(configure with --with-pydebug). It catches some errors earlier and sometimes more
reliably.
----------
nosy: +amaury.forgeotdarc
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4358>
_______________________________________
More information about the Python-bugs-list
mailing list