I am having a problem calling a shared c library from python. The library loads fine and one of the 3 functions exposed are callable, and work as expected; however, when adding another function to the library, I found that the other two do not work. What happens is that python hangs on the actual function call and just spins while doing nothing. Both the python side and the c side have detailed logging, and I can tell that the function in the library isn't even starting because none of the debug files are being written.
Below is a small snippet of the code in question:
This is the c code sample function that is failing:
int genTest(char* filePath)
{
infoPrint(filePath, 2);
return EXIT_SUCCESS;
}
this is the python that I am calling it with:
import ctypes as C
lg.create_log_entry('loading dll... from ' + str(lib_path) + str(lib_name))
myclib = C.CDLL(lib_path + lib_name)
lg.create_log_entry('loaded')
genTest = myclib.genTest
genTest.argtypes = [C.c_char_p]
genTest.restype = C.c_int
lg.create_log_entry('test start')
res = genTest(C.c_char_p(str(source_as_image)))
certirxlogging.create_log_entry('test successful')
This code gets to writing 'test start' and hangs. Like I said, this works fine on another function in the library elsewhere in the python code, and python isn't throwing me any errors, so, I am unable to debug anything. Any ideas?
gdband produce a backtrace when it hangs. That might help you figure out where to look. What doesinfoPrintdo? Are you sure thatfilePathis non-NULL whengenTestis called?clang -shared -oct.dylib ct.c, and ran, and everything worked. So, what's different in your test than in mine?