Python - cdll immediately crashes program after upgrading from Python 2.7 to 3.8

1

I am in the process of upgrading a project from python 2.7 to 3.8, which involved a call of a function from a dll. This dll was actually generated with MATLAB's codegen utility.

The header of the function shown in the .h file from the codegen utility (edited to obscure any details) states:

extern void example_func(const double inputArray[12], const struct0_T *inputStruct, double
    value1, double value2, double value3, double returnArray[12]);

Now, with Python 2.7 I was able to call this function with the following steps:

from ctypes import *

myDll = cdll.LoadLibrary(path_to_my_library)

# initialized values like so:
inputArray = (c_double*12)()
returnArray = (c_double*12)()
value1 = c_double(value) # etc.
# ...
# ...
# later in the code, after making sure all inputs were cast to the correct ctypes
result = []
myDll.example_func(inputArray, inputStruct, value1, value2, value3, returnArray)

for i in range(0, 12):
    result.append(returnArray[i])

This would return the result I was expecting into "result"

Now, when I try and do the same thing with python 3.8, I get to the point where I call myDll.example_func(...), and it immediately terminates the program, and I get the error code: Process finished with exit code -1073741819 (0xC0000005)

The DLL is 64-bit, and I am using the 64-bit version of Python 3.8.

I am not sure where to go from here, any direction or help would be appreciated.

python
python-2.7
matlab
dll
python-3.8
asked on Stack Overflow Apr 10, 2020 by malnooshna

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0