samedi 14 août 2021

Why does PyObject_CallMethod sometimes cause an access violation?

I am trying to call a method from a class from c++ and I do this by storing the pyobject pointer in a vector and then iterating through the vector. The method takes one argument that is a doulbe. Here is the code c++:

for (auto obj : _physicsList)
{
    auto _double = GetDouble();
    PyObject_CallMethod(obj, "PhysicsTick", "d", _double);
}

It sometimes does this:

Exception in thread Thread-1:

Traceback (most recent call last):

...

OSError: exception: access violation reading 0x0000000000000058

I don't see why this would cause an access violation espectailly when I am using Py_INCREF and Py_DECREF to handle the references when the obj is added or removed from the vector.

This is on x64 and is a multi threaded app.

Aucun commentaire:

Enregistrer un commentaire