test: add regression test for PYBIND11_MAKE_OPAQUE with std::array (issue #5988)#6006
Draft
test: add regression test for PYBIND11_MAKE_OPAQUE with std::array (issue #5988)#6006
Conversation
…rray and nested containers Co-authored-by: henryiii <4616906+henryiii@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix crash in pybind11 when using std containers
test: add regression test for PYBIND11_MAKE_OPAQUE with std::array (issue #5988)
Mar 7, 2026
Collaborator
|
pre-commit.ci autofix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pybind11 3.0.2 crashes on Windows (Python 3.11/MSVC) during module initialization when
PYBIND11_MAKE_OPAQUEis used withstd::arraytypes. The crash trace shows a null pointer access violation insidepybind11::detail::get_internals()→Thrd_yield(MSVCP140.dll), triggered at import time.This PR adds a regression test exercising
PYBIND11_MAKE_OPAQUEwithstd::array<double, 3>and the nestedstd::vector<std::array<double, 3>>— types not currently covered by any test and safe from ODR conflicts (unlikestd::array<int, 3>which is used as a converted type intest_stl.cpp):tests/test_opaque_types.cpp: AddsPYBIND11_MAKE_OPAQUEdeclarations forstd::array<double, 3>andstd::vector<std::array<double, 3>>, withpy::class_bindings exposing indexing, mutation, and length operations.tests/test_opaque_types.py: Addstest_issue_5988_opaque_std_array()covering element access, bounds checking (IndexError), and vector-of-array operations.Suggested changelog entry:
PYBIND11_MAKE_OPAQUEwithstd::arrayand nestedstd::vector<std::array<...>>types.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.