Pointer function argument corrupted, Stack corruption?
<p>Im building a C++ library which gets called by python via ctypes. The function has as parameter a pointer to a struct and passes it to other (internal) function. It looks like this:</p>

<pre><code>extern "C" __declspec(dllexport) void USBEndpoint_subscribe(USBEndpoint* endpoint, CALLBACK callback) {
  try {
    subscribe_internal(endpoint, callback);
  } catch (int e_code) {
    exception_report(__FILE__, __LINE__, e_code); \
  } catch (...) {
    exception_report(__FILE__, __LINE__);
}

void subscribe_internal(USBEndpoint* endpoint, CALLBACK callback)
{
  ...
}
</code></pre>

<p>The thing is that the value for endpoint recieved at USBEndpoint_subscribe is not the same value that enters subscribe_internal. For example:</p>

<p>while debugging I can see that USBEndpoint_subscribe recieves:
endpoint=0x00000000088f0680 (and callback=0x0000000000540f50)</p>

<p>and as soon as I step into subscribe_internal, inside subscribe_internal the values are:
endpoint=0x000007fef15f7740 (and callback=0x0000000000000000).</p>

<p>I have not spawn other threads and I'm compiling the library in release mode**. My only suspect could be stack corruption, but actually I have clue of what's going on.</p>

<p>Any hints of what can be happening are very welcome.</p>

<p>** I have compiled python in debug mode, but it's slow to set up with spider and I loose the interactive console if I use my debug-compiled version, so I prefer sticking with release python and compiling my library in release.</p>

<p>EDIT:</p>

<p>As suggested, I used my debug version of python with a debug compile of the library. But I still got the same behavior (endpoint: 0x0000000002be80e0->0x0000000000000000, callback: 0x0000000000320f88->0x00000000024d24b8). No other useful information appeared here that wasn't in release mode.</p>