-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Labels
Description
Bug report
Bug description:
I spent a few hours yesterday debugging this, and thus thought I had to point it out.
Here's my simplified C++ code:
struct Example {
// Lots of stuff, pointers, stuff like that
}
typedef struct {
PyObject ob_base;
struct A Example;
} ExampleObject;
static PyTypeObject ExampleType = {
.ob_base = PyVarObject_HEAD_INIT(NULL, 0).tp_name = "my_module.Example",
.tp_basicsize = sizeof(ExampleObject),
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_new = PyType_GenericNew,
};
static PyObject * foo(PyObject* self, PyObject * args) {
auto* temp = PyObject_New(ExampleObject, &ExampleType);
// The issue is here
}
The issues lies in the fact that, according to the documentation, the content of temp
should be initialized at NULL
, but that is clearly not the case here: I printed each byte of temp, and some of them clearly were not NULL.
This silent error caused me many a troubles. I fixed this by using memset
, but I really shouldn't have to, so please fix this.
Thanks !
CPython versions tested on:
3.13
Operating systems tested on:
Linux