Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation error happens in Embedding Python. #53163

Closed
tanaga mannequin opened this issue Jun 6, 2010 · 4 comments
Closed

Segmentation error happens in Embedding Python. #53163

tanaga mannequin opened this issue Jun 6, 2010 · 4 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-ctypes type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@tanaga
Copy link
Mannequin

tanaga mannequin commented Jun 6, 2010

BPO 8917
Nosy @theller
Files
  • ctypes_segmfault.c
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/theller'
    closed_at = <Date 2010-07-19.10:41:43.788>
    created_at = <Date 2010-06-06.14:47:40.537>
    labels = ['interpreter-core', 'ctypes', 'type-crash']
    title = 'Segmentation error happens in Embedding Python.'
    updated_at = <Date 2010-07-19.16:34:32.562>
    user = 'https://bugs.python.org/tanaga'

    bugs.python.org fields:

    activity = <Date 2010-07-19.16:34:32.562>
    actor = 'tanaga'
    assignee = 'theller'
    closed = True
    closed_date = <Date 2010-07-19.10:41:43.788>
    closer = 'ocean-city'
    components = ['Interpreter Core', 'ctypes']
    creation = <Date 2010-06-06.14:47:40.537>
    creator = 'tanaga'
    dependencies = []
    files = ['17572']
    hgrepos = []
    issue_num = 8917
    keywords = []
    message_count = 4.0
    messages = ['107194', '107195', '110729', '110775']
    nosy_count = 3.0
    nosy_names = ['theller', 'ocean-city', 'tanaga']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue8917'
    versions = ['Python 2.6']

    @tanaga
    Copy link
    Mannequin Author

    tanaga mannequin commented Jun 6, 2010

    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]$

    @tanaga tanaga mannequin assigned theller Jun 6, 2010
    @tanaga tanaga mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-ctypes type-crash A hard crash of the interpreter, possibly with a core dump labels Jun 6, 2010
    @tanaga
    Copy link
    Mannequin Author

    tanaga mannequin commented Jun 6, 2010

    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.

    >>

    @ocean-city
    Copy link
    Mannequin

    ocean-city mannequin commented Jul 19, 2010

    I think this issue is duplicates of bpo-6869. So I'm closing...

    @ocean-city ocean-city mannequin closed this as completed Jul 19, 2010
    @tanaga
    Copy link
    Mannequin Author

    tanaga mannequin commented Jul 19, 2010

    Thanx Hirokazu Yamamoto!! (arigato gozaimasu)

    I was insufficient when search.
    I searched keywords "segment ctype" that didn't match :(

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-ctypes type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant