My code is very large so I am not going to post it here. I will just try to explain the best I can.
My C++ program:
I have an Image class that Loads images and Binds them to OpenGL image objects. If there is already an image loaded for the current class it will free it and then load the new image. I have a function called New that takes 3 perameters: Width, Height, and Bpp. It frees already used data, and resizes the image.
I am trying to integrate Python into my program via Python C/Api. I made/am making a wrapper class in python for my Image class. I can get and set all the variables in the Image class. But when I call New(Width, Height, Bpp) from Python it causes a SEGV.
I tracked it down to the New member call in my program... Kinda.
It goes something like this:
Code:
PyObject *Py_Image_New(PyObject *Self, PyObject *Args)
{
//Get args
returnValue=(typcast(Self))->New(Width, Height, Bpp);
return PyBuildObject("i",returnValue);
}
This causes a Segmentation fault. However, the call to New finishes succefully.
This is where it gets hairy:
If I put a fprintf(stderr, "Something\n"); after the call to New, then my program runs fine without any problems!
I tried using DDD to debug it, but I can't track anything because Python calls my function via a pointer, so DDD can't track it.
Why would a simple call to fprint fix a SEGV?
What am I doing wrong?