[issue35350] importing "ctypes" immediately causes a segmentation fault

David report at bugs.python.org
Fri Nov 30 08:27:43 EST 2018


David <raging.blaze at gmail.com> added the comment:

Another small update:

After I recompiled Python with the commented out statement, I did a small test if loading a shared library works.

I compiled the following test function to testib.so:

#include <stdio.h>

void test_func(void);

void test_func(void) {
	printf("hello world\n");
}

After that I used ctypes to load this library and execute the test_func():

(gdb) file python2.7
Reading symbols from python2.7...done.
(gdb) run -c "import ctypes; lib_test = ctypes.cdll.LoadLibrary('/tmp/testlib.so'); lib_test.test_func();"
Starting program: /usr/bin/python2.7 -c "import ctypes; lib_test = ctypes.cdll.LoadLibrary('/tmp/testlib.so'); lib_test.test_func();"
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
hello world

Program received signal SIGSEGV, Segmentation fault.
PyCFuncPtr_call (self=<optimized out>, inargs=<optimized out>, kwds=<optimized out>) at /home/user/ARM_Linux/src/Python-2.7.15/Modules/_ctypes/_ctypes.c:4108
4108    /home/user/ARM_Linux/src/Python-2.7.15/Modules/_ctypes/_ctypes.c: No such file or directory.
(gdb)

It prints the expected output, but again I get a segmentation fault, this time in PyCFuncPtr_call function.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35350>
_______________________________________


More information about the Python-bugs-list mailing list