Issue8917
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010-06-06 14:47 by tanaga, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
ctypes_segmfault.c | tanaga, 2010-06-06 14:47 |
Messages (4) | |||
---|---|---|---|
msg107194 - (view) | Author: tanaga (tanaga) | Date: 2010-06-06 14:47 | |
A segmentation error happens in Embedding Python. condition When I called four times of Py_Main in one process. and When I used ctypes in the script. A happening segmentation error(core dumped) [user@localhost debug]$ [user@localhost debug]$ ls -l total 24 -rwxrwxrwx 1 user user 333 May 30 03:17 build.sh -rwxrwxrwx 1 user user 385 Jun 6 23:27 ctypes_segmfault.c -rwxrwxrwx 1 user user 14 Jun 6 23:25 import_ctypes.py [user@localhost debug]$ [user@localhost debug]$ [user@localhost debug]$ ./build.sh /usr/local/lib/libpython2.6.a(posixmodule.o): In function `posix_tmpnam': /work/Python-2.6.5/./Modules/posixmodule.c:7207: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp' /usr/local/lib/libpython2.6.a(posixmodule.o): In function `posix_tempnam': /work/Python-2.6.5/./Modules/posixmodule.c:7162: warning: the use of `tempnam' is dangerous, better use `mkstemp' [user@localhost debug]$ [user@localhost debug]$ [user@localhost debug]$ ls -l total 4212 -rwxrwxrwx 1 user user 333 May 30 03:17 build.sh -rwxrwxr-x 1 user user 4256056 Jun 6 23:30 ctypes_segmfault -rwxrwxrwx 1 user user 385 Jun 6 23:27 ctypes_segmfault.c -rw-rw-r-- 1 user user 4664 Jun 6 23:30 ctypes_segmfault.o -rwxrwxrwx 1 user user 14 Jun 6 23:25 import_ctypes.py [user@localhost debug]$ [user@localhost debug]$ [user@localhost debug]$ ./ctypes_segmfault ----- 0 ----- ----- 1 ----- ----- 2 ----- ----- 3 ----- Segmentation fault (core dumped) [user@localhost debug]$ [user@localhost debug]$ [user@localhost debug]$ ls -l total 5960 -rwxrwxrwx 1 user user 333 May 30 03:17 build.sh -rw------- 1 user user 1933312 Jun 6 23:31 core.2981 -rwxrwxr-x 1 user user 4256056 Jun 6 23:30 ctypes_segmfault -rwxrwxrwx 1 user user 385 Jun 6 23:27 ctypes_segmfault.c -rw-rw-r-- 1 user user 4664 Jun 6 23:30 ctypes_segmfault.o -rwxrwxrwx 1 user user 14 Jun 6 23:25 import_ctypes.py [user@localhost debug]$ so I watched core with gdb. [user@localhost debug]$ gdb ctypes_segmfault core.2981 GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5_5.1) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/user/debug/ctypes_segmfault...done. warning: core file may not match specified executable file. Reading symbols from /lib/libpthread.so.0...(no debugging symbols found)...done. Loaded symbols for /lib/libpthread.so.0 Reading symbols from /lib/libdl.so.2...(no debugging symbols found)...done. Loaded symbols for /lib/libdl.so.2 Reading symbols from /lib/libutil.so.1...(no debugging symbols found)...done. Loaded symbols for /lib/libutil.so.1 Reading symbols from /lib/libm.so.6...(no debugging symbols found)...done. Loaded symbols for /lib/libm.so.6 Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done. Loaded symbols for /lib/libc.so.6 Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done. Loaded symbols for /lib/ld-linux.so.2 Reading symbols from /usr/local/lib/python2.6/lib-dynload/_ctypes.so...done. Loaded symbols for /usr/local/lib/python2.6/lib-dynload/_ctypes.so Reading symbols from /usr/local/lib/python2.6/lib-dynload/_struct.so...done. Loaded symbols for /usr/local/lib/python2.6/lib-dynload/_struct.so Core was generated by `./ctypes_segmfault'. Program terminated with signal 11, Segmentation fault. #0 0x080a103a in type_dealloc (type=0x9f3180) at Objects/typeobject.c:2610 2610 _PyObject_GC_UNTRACK(type); (gdb) bt #0 0x080a103a in type_dealloc (type=0x9f3180) at Objects/typeobject.c:2610 #1 0x080888ef in dict_dealloc (mp=0xb7ef313c) at Objects/dictobject.c:911 #2 0x080888ef in dict_dealloc (mp=0xb7f4c02c) at Objects/dictobject.c:911 #3 0x080e7599 in _PyImport_Fini () at Python/import.c:240 #4 0x080f47cc in Py_Finalize () at Python/pythonrun.c:460 #5 0x08058183 in Py_Main (argc=1, argv=0xbfe5c6c8) at Modules/main.c:596 #6 0x080579d3 in main () at ./ctypes_segmfault.c:16 (gdb) quit [user@localhost debug]$ fumm... I don't know about inside of Python Interpreter. [user@localhost debug]$ cat ctypes_segmfault.c #include <stdio.h> #include <Python.h> /* ulimit -c unlimited */ int main(void) { char *argpy[] = { "python", "import_ctypes.py" }; printf("----- 0 -----\n"); Py_Main(2, argpy); printf("----- 1 -----\n"); Py_Main(2, argpy); printf("----- 2 -----\n"); Py_Main(2, argpy); printf("----- 3 -----\n"); Py_Main(2, argpy); printf("----- 4 -----\n"); return 0; } [user@localhost debug]$ [user@localhost debug]$ cat build.sh #!/bin/sh gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 \ -Wall -Wstrict-prototypes -I/usr/local/include/python2.6/ \ -DPy_BUILD_CORE -o ctypes_segmfault.o ./ctypes_segmfault.c gcc -pthread -Xlinker -export-dynamic -o ctypes_segmfault \ ctypes_segmfault.o \ -lpython2.6 -lpthread -ldl -lutil -lm [user@localhost debug]$ [user@localhost debug]$ cat import_ctypes.py import ctypes [user@localhost debug]$ |
|||
msg107195 - (view) | Author: tanaga (tanaga) | Date: 2010-06-06 16:50 | |
I used Python 2.6.5 on CentOS 5.5. [root@localhost ~]# uname -a Linux localhost.localdomain 2.6.18-194.3.1.el5 #1 SMP Thu May 13 13:09:10 EDT 2010 i686 i686 i386 GNU/Linux [root@localhost ~]# python Python 2.6.5 (r265:79063, May 30 2010, 03:05:19) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> |
|||
msg110729 - (view) | Author: Hirokazu Yamamoto (ocean-city) * ![]() |
Date: 2010-07-19 10:41 | |
I think this issue is duplicates of Issue6869. So I'm closing... |
|||
msg110775 - (view) | Author: tanaga (tanaga) | Date: 2010-07-19 16:34 | |
Thanx Hirokazu Yamamoto!! (arigato gozaimasu) I was insufficient when search. I searched keywords "segment ctype" that didn't match :( |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:01 | admin | set | github: 53163 |
2010-07-19 16:34:32 | tanaga | set | messages: + msg110775 |
2010-07-19 10:41:43 | ocean-city | set | status: open -> closed nosy: + ocean-city messages: + msg110729 resolution: duplicate |
2010-06-06 16:50:59 | tanaga | set | messages: + msg107195 |
2010-06-06 14:47:40 | tanaga | create |