'Ctypes: OSError: exception: stack overflow
C++
this code work in exe, but not working in dll when python is used.
Python throw this error when program run to dec(&buffer2, &length, &buffer);
.
Both python and dll are x64.
#include "Decompress.h"
#pragma comment (lib,"Decompress.lib")
#define DLLEXPORT extern "C" __declspec(dllexport)
DLLEXPORT void try_dec()
{
int buffer[20];
int buffer2[20];
int length = 20;
dec(&buffer2, &length, &buffer);
return;
}
Python
import ctypes
dll = ctypes.CDLL('Dec.dll')
dll.try_dec()
Error
dll.dec()
OSError: exception: stack overflow
Solution 1:[1]
the function will call itself and you end up in an infinite loop resulting in the stack overflow. To prevent this sort of errors you should change your functions signature to
void dec (void)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | M.Knaup |