BUG: fix segfault on deeply nested structured dtype (gh-32488) - #32622
BHUVANSH855 wants to merge 3 commits into
Conversation
|
max test failures are real |
|
Hi, @BHUVANSH855 ! Thank you for your interest in contributing to NumPy. As the label indicates, #32488 is reserved for participants in the NumFOCUS Sustaining Open Source Series. As well as #32609. Could you let us know which organization you’re part of? |
|
@ngoldbaum @InessaPawson |
Hmmm... Isn't the board titled NumFOCUS Sustaining Open Source Series 2026?...
@BHUVANSH855 Please do not take any additional issues from this board, as these issues are reserved for participants in the program. |

PR summary
Fixes #32488.
Creating an array from a sufficiently deeply nested structured dtype segfaults instead of raising a catchable exception. Resolving the zerofill traverse function for such a dtype recurses once per nesting level in
npy_get_zerofill_void_and_legacy_user_dtype_loop, with no termination check, so a deep enough dtype exhausts the C stack.The fix adds a
Py_EnterRecursiveCallguard via a thin wrapper around the existing function, following the same pattern used for self-containing arrays (gh-8306, gh-9077).This fixes the crash as reported in the issue (verified against the reporter's own repro, which now raises
RecursionErrorinstead of segfaulting). It does not fully cover the artificially small (1 MiB) thread-stack reproducer also posted in the issue, that's a general limitation of counter-based recursion guards rather than something specific to this fix, same caveat noted in gh-32620.Added a regression test in
TestMonsterTypefollowing the existingtest_dict_recursion/test_list_recursionstyle. Ran the fulltest_dtype.pysuite (1181 passed) and the zerofill/structured/dtype subset oftest_multiarray.py(195 passed) with no regressions.First time contributor introduction
Still new to numpy, background in CPython tooling. Found this one from the "Looking for Contributor" board after that PR.
AI Disclosure
No AI tools used.