Skip to content

BUG: doc build on 3.14t interpreter leads to bus error #30681

@ngoldbaum

Description

@ngoldbaum

When I run PYTHONFAULTHANDLER=1 spin docs with a free-threaded interpreter on my ARM Macbook Pro, the doc build crashes with a bus error and the following faulthandler output:

Details
Running Sphinx v7.2.6
Fatal Python error: Segmentation fault

<Cannot show all threads while the GIL is disabled>
Stack (most recent call first):
  File "/Users/goldbaum/Documents/numpy/doc/source/conf.py", line 58 in replace_scalar_type_names
  File "/Users/goldbaum/Documents/numpy/doc/source/conf.py", line 65 in <module>
  File "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/python3.14t/site-packages/sphinx/config.py", line 358 in eval_config_file
  File "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/python3.14t/site-packages/sphinx/config.py", line 181 in read
  File "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/python3.14t/site-packages/sphinx/application.py", line 211 in __init__
  File "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/python3.14t/site-packages/sphinx/cmd/build.py", line 293 in build_main
  File "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/python3.14t/site-packages/sphinx/cmd/build.py", line 341 in main
  File "/Users/goldbaum/.pyenv/versions/3.14.2t/bin/sphinx-build", line 7 in <module>

Current thread's C stack trace (most recent call first):
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _Py_DumpStack+0x44 [0x105744a64]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at faulthandler_fatal_error+0x240 [0x1057588d4]
  Binary file "/usr/lib/system/libsystem_platform.dylib", at _sigtramp+0x38 [0x189d4d6a4]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at setitem_take2_lock_held+0x3c [0x1055a1c2c]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at PyDict_SetItem+0x100 [0x1055a1ebc]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _PyEval_EvalFrameDefault+0xf728 [0x1056ad6b0]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at PyEval_EvalCode+0x25c [0x10569da00]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at builtin_exec+0x608 [0x105699278]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at PyObject_Vectorcall+0x58 [0x10554df98]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _PyEval_EvalFrameDefault+0x2364 [0x1056a02ec]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _PyEval_Vector+0x2cc [0x10569dce0]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _PyObject_VectorcallDictTstate+0xcc [0x10554d658]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _PyObject_Call_Prepend+0x98 [0x10554e88c]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at call_method+0x7c [0x105600284]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at slot_tp_init+0x2c [0x105608678]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at type_call+0x1c0 [0x1055f806c]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _PyObject_MakeTpCall+0x148 [0x10554d804]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _PyEval_EvalFrameDefault+0x2364 [0x1056a02ec]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at PyEval_EvalCode+0x25c [0x10569da00]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at run_mod+0x270 [0x105729ef0]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _PyRun_SimpleFileObject+0x390 [0x1057269a4]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at _PyRun_AnyFileObject+0xa0 [0x10572626c]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at pymain_run_file+0x14c [0x105754d5c]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at Py_RunMain+0x778 [0x105754428]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at pymain_main+0x144 [0x10575477c]
  Binary file "/Users/goldbaum/.pyenv/versions/3.14.2t/lib/libpython3.14t.dylib", at Py_BytesMain+0x28 [0x10575481c]
  Binary file "/usr/lib/dyld", at start+0x17bc [0x189972b98]

Extension modules: PIL._imaging, markupsafe._speedups, numpy._core._multiarray_umath, numpy.linalg._umath_linalg (total: 4)
make: *** [html-build] Segmentation fault: 11

The most relevant line in the Python traceback is:

File "/Users/goldbaum/Documents/numpy/doc/source/conf.py", line 58 in replace_scalar_type_names

Which corresponds to this line:

c_typ.tp_name = _name_cache[typ] = b"numpy." + name.encode('utf8')

I'm pretty sure that writing to tp_name like this via ctypes is undefined behavior. For static types tp_name is embedded in the binary. I'm a little surprised it works at all in the GIL-enabled build.

Ping @mattip since you last touched this code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions