[pypy-issue] Issue #3055: Segfault when defining a C extension type with empty docstring on PyPy3 (pypy/pypy)
timfel
issues-reply at bitbucket.org
Fri Aug 16 05:43:23 EDT 2019
New issue 3055: Segfault when defining a C extension type with empty docstring on PyPy3
https://bitbucket.org/pypy/pypy/issues/3055/segfault-when-defining-a-c-extension-type
timfel:
Given this type definition, we get a segfault when calling `PyType_Ready` on it:
```c
static PyTypeObject NativeType = {
PyVarObject_HEAD_INIT(NULL, 0)
"NativeType.NativeType",
sizeof(NativeTypeObject),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
Py_TPFLAGS_DEFAULT,
"",
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
PyType_GenericAlloc,
PyType_GenericNew,
PyObject_Del,
};
```
We can avoid the segfault if we give `0` or `NULL` instead of the empty docstring in line 22. Or just adding any character to make the docstring longer than 0-length also makes it work.
More information about the pypy-issue
mailing list