Message371796
Python Process crashes with unauthorised memory access when the C++ DLL callback has arguments as structures. Happens in python 3.8. python 3.7 works fine with same source code. Initial investigations revels that the structure is called back as a pointer instead of plain python object. Callbacks with Primitive types are successful. This might be something to do with vector calling in python 3.8?
>>>Replicate:
>>>A c++ DLL with "subscribe_cb" function and a callback "listen_cb"; where FILETIME is windows FILETIME structure (it can be any structure for that matter)
extern "C" CBFUNC(void, listen_cb)(int value, FILETIME ts );
extern "C" EXFUNC(void) subscribe_cb(listen_cb);
EXFUNC(void) subscribe_cb(listen_cb cb)
{
int i = 0;
while (true) {
FILETIME systime;
GetSystemTimeAsFileTime(&systime);
i++;
Sleep(1000);
cb(i, systime);
}
}
>>>Python client for the dll
class FT(Structure):
_fields_ = [("dwLowDateTime", c_ulong, 32),
("dwHighDateTime", c_ulong, 32)]
@WINFUNCTYPE(c_void_p, c_int, FT)
def cb(val, ft):
print(f"callback {val} {ft.dwLowDateTime} {ft.dwHighDateTime}")
lib = WinDLL(r"C:\Temp\CBsimulate\CbClient\CbClient\Debug\DummyCb.dll")
lib.subscribe_cb(cb)
while 1:
sleep(5) |
|
Date |
User |
Action |
Args |
2020-06-18 09:26:16 | itsgk92 | set | recipients:
+ itsgk92, amaury.forgeotdarc, belopolsky, meador.inge |
2020-06-18 09:26:16 | itsgk92 | set | messageid: <1592472376.78.0.985098642017.issue41021@roundup.psfhosted.org> |
2020-06-18 09:26:16 | itsgk92 | link | issue41021 messages |
2020-06-18 09:26:16 | itsgk92 | create | |
|