Skip to content

Python 3.7.13 - Segmentation fault on import #92825

Closed as not planned
Closed as not planned
@diasjoaocarlos

Description

@diasjoaocarlos

Python Environment:

Python 3.7.13 (default, Mar 28 2022, 07:24:34)
[Clang 12.0.0 ]

on Anaconda:
conda version : 4.12.0
conda-build version : 3.20.5
python version : 3.7.13.final.0
virtual packages : __osx=10.15.7=0
__unix=0=0
__archspec=1=x86_64

On:
$ lldb python
(lldb) target create "python"
Current executable set to 'python' (x86_64).
(lldb) run
Process 11715 launched: '/Users/Joao/anaconda3/bin/python' (x86_64)
Python 3.7.13 (default, Mar 28 2022, 07:24:34)
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.

import myextension
Process 11715 stopped

  • thread Support "bpo-" in Misc/NEWS #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
    frame #0: 0x0000000103077d9b libpython3.7m.dylibPyModule_Create2 + 11 libpython3.7m.dylibPyModule_Create2:
    -> 0x103077d9b <+11>: movq 0x10(%rax), %rax
    0x103077d9f <+15>: cmpq $0x0, 0x28(%rax)
    0x103077da4 <+20>: je 0x103077dac ; <+28>
    0x103077da6 <+22>: popq %rbp
    Target 0: (python) stopped.
    (lldb)
    (lldb) reg read rax
    rax = 0x0000000000000000
    (lldb) disass
    libpython3.7m.dylib`PyModule_Create2:
    0x103077d90 <+0>: pushq %rbp
    0x103077d91 <+1>: movq %rsp, %rbp
    0x103077d94 <+4>: movq 0x2576fd(%rip), %rax ; _PyRuntime + 1528
    -> 0x103077d9b <+11>: movq 0x10(%rax), %rax

The module 'myextension.so' was made using:
gcc -DNDEBUG -g -O3 -Wall -fPIC -I/Users/Joao/anaconda3/include/python3.7m/ -c myextension.c
gcc -shared myextension.o -L/Users/Joao/anaconda3/lib/ -lpython3.7m -o myextension.so

And code is 'myextension.c', using the Python C API (using Python.h):

PyMODINIT_FUNC
PyInit_myextension(void)
{
#if PY_MAJOR_VERSION >= 3
PyObject *module = PyModule_Create(&moduledef);
#else
PyObject *module = Py_InitModule("myextension", myextension_methods);
#endif
...

Using bash and running python:

$ python
Python 3.7.13 (default, Mar 28 2022, 07:24:34)
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.

import myextension
zsh: segmentation fault python

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-mactype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions