Reputation: 3665
I have developed a library using C++ and C; and the library is working fine with my C++ test program; but it gave me a segmentation fault when the library is used in Python using c_types.
Also, my library works fine under 64 bit OS when I use c_types or C++ test program, it crashes when I switched to 32 bit OS. And my C++ test program works fine on 32 bit OS.
This is very weird.
Anyone knows how to debug the Python and c_types library together?
Or do you have any suggestion?
Upvotes: 0
Views: 122
Reputation: 3665
I think this answer is better:
In a summary, just run the following:
gdb python
//after gdb is running, type the following command
run test_case.py *arguments_of_your_script*
gdb will stop when it find a segmentation fault in the python c_types library.
After that, just run the common gdb command to examine the memory and registers.
Upvotes: 0
Reputation: 11002
The right is to do it is to launch gdb with pdb.
An example here : calling functions returned as pointers from other functions in ctypes
Upvotes: 1