* Fix data race all_type_info_populate in free-threading mode
Description:
- fixed data race all_type_info_populate in free-threading mode
- added test
For example, we have 2 threads entering `all_type_info`.
Both enter `all_type_info_get_cache`` function and
there is a first one which inserts a tuple (type, empty_vector) to the map
and second is waiting. Inserting thread gets the (iter_to_key, True) and non-inserting thread
after waiting gets (iter_to_key, False).
Inserting thread than will add a weakref and will then call into `all_type_info_populate`.
However, non-inserting thread is not entering `if (ins.second) {` clause and
returns `ins.first->second;`` which is just empty_vector.
Finally, non-inserting thread is failing the check in `allocate_layout`:
```c++
if (n_types == 0) {
pybind11_fail(
"instance allocation failed: new instance has no pybind11-registered base types");
}
```
* style: pre-commit fixes
* Addressed PR comments
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
| Name |
Last commit
|
Last Update |
|---|---|---|
| .. | ||
| extra_python_package | Loading commit data... | |
| extra_setuptools | Loading commit data... | |
| test_cmake_build | Loading commit data... | |
| test_embed | Loading commit data... | |
| CMakeLists.txt | Loading commit data... | |
| conftest.py | Loading commit data... | |
| constructor_stats.h | Loading commit data... | |
| cross_module_gil_utils.cpp | Loading commit data... | |
| cross_module_interleaved_error_already_set.cpp | Loading commit data... | |
| custom_exceptions.py | Loading commit data... | |
| eigen_tensor_avoid_stl_array.cpp | Loading commit data... | |
| env.py | Loading commit data... | |
| exo_planet_c_api.cpp | Loading commit data... | |
| exo_planet_pybind11.cpp | Loading commit data... | |
| home_planet_very_lonely_traveler.cpp | Loading commit data... | |
| local_bindings.h | Loading commit data... | |
| object.h | Loading commit data... | |
| pybind11_cross_module_tests.cpp | Loading commit data... | |
| pybind11_tests.cpp | Loading commit data... | |
| pybind11_tests.h | Loading commit data... | |
| pyproject.toml | Loading commit data... | |
| pytest.ini | Loading commit data... | |
| requirements.txt | Loading commit data... | |
| test_async.cpp | Loading commit data... | |
| test_async.py | Loading commit data... | |
| test_buffers.cpp | Loading commit data... | |
| test_buffers.py | Loading commit data... | |
| test_builtin_casters.cpp | Loading commit data... | |
| test_builtin_casters.py | Loading commit data... | |
| test_call_policies.cpp | Loading commit data... | |
| test_call_policies.py | Loading commit data... | |
| test_callbacks.cpp | Loading commit data... | |
| test_callbacks.py | Loading commit data... | |
| test_chrono.cpp | Loading commit data... | |
| test_chrono.py | Loading commit data... | |
| test_class.cpp | Loading commit data... | |
| test_class.py | Loading commit data... | |
| test_const_name.cpp | Loading commit data... | |
| test_const_name.py | Loading commit data... | |
| test_constants_and_functions.cpp | Loading commit data... | |
| test_constants_and_functions.py | Loading commit data... | |
| test_copy_move.cpp | Loading commit data... | |
| test_copy_move.py | Loading commit data... | |
| test_cpp_conduit.cpp | Loading commit data... | |
| test_cpp_conduit.py | Loading commit data... | |
| test_cpp_conduit_traveler_bindings.h | Loading commit data... | |
| test_cpp_conduit_traveler_types.h | Loading commit data... | |
| test_custom_type_casters.cpp | Loading commit data... | |
| test_custom_type_casters.py | Loading commit data... | |
| test_custom_type_setup.cpp | Loading commit data... | |
| test_custom_type_setup.py | Loading commit data... | |
| test_docstring_options.cpp | Loading commit data... | |
| test_docstring_options.py | Loading commit data... | |
| test_eigen_matrix.cpp | Loading commit data... | |
| test_eigen_matrix.py | Loading commit data... | |
| test_eigen_tensor.cpp | Loading commit data... | |
| test_eigen_tensor.inl | Loading commit data... | |
| test_eigen_tensor.py | Loading commit data... | |
| test_enum.cpp | Loading commit data... | |
| test_enum.py | Loading commit data... | |
| test_eval.cpp | Loading commit data... | |
| test_eval.py | Loading commit data... | |
| test_eval_call.py | Loading commit data... | |
| test_exceptions.cpp | Loading commit data... | |
| test_exceptions.h | Loading commit data... | |
| test_exceptions.py | Loading commit data... | |
| test_factory_constructors.cpp | Loading commit data... | |
| test_factory_constructors.py | Loading commit data... | |
| test_gil_scoped.cpp | Loading commit data... | |
| test_gil_scoped.py | Loading commit data... | |
| test_iostream.cpp | Loading commit data... | |
| test_iostream.py | Loading commit data... | |
| test_kwargs_and_defaults.cpp | Loading commit data... | |
| test_kwargs_and_defaults.py | Loading commit data... | |
| test_local_bindings.cpp | Loading commit data... | |
| test_local_bindings.py | Loading commit data... | |
| test_methods_and_attributes.cpp | Loading commit data... | |
| test_methods_and_attributes.py | Loading commit data... | |
| test_modules.cpp | Loading commit data... | |
| test_modules.py | Loading commit data... | |
| test_multiple_inheritance.cpp | Loading commit data... | |
| test_multiple_inheritance.py | Loading commit data... | |
| test_numpy_array.cpp | Loading commit data... | |
| test_numpy_array.py | Loading commit data... | |
| test_numpy_dtypes.cpp | Loading commit data... | |
| test_numpy_dtypes.py | Loading commit data... | |
| test_numpy_vectorize.cpp | Loading commit data... | |
| test_numpy_vectorize.py | Loading commit data... | |
| test_opaque_types.cpp | Loading commit data... | |
| test_opaque_types.py | Loading commit data... | |
| test_operator_overloading.cpp | Loading commit data... | |
| test_operator_overloading.py | Loading commit data... | |
| test_pickling.cpp | Loading commit data... | |
| test_pickling.py | Loading commit data... | |
| test_python_multiple_inheritance.cpp | Loading commit data... | |
| test_python_multiple_inheritance.py | Loading commit data... | |
| test_pytypes.cpp | Loading commit data... | |
| test_pytypes.py | Loading commit data... | |
| test_sequences_and_iterators.cpp | Loading commit data... | |
| test_sequences_and_iterators.py | Loading commit data... | |
| test_smart_ptr.cpp | Loading commit data... | |
| test_smart_ptr.py | Loading commit data... | |
| test_stl.cpp | Loading commit data... | |
| test_stl.py | Loading commit data... | |
| test_stl_binders.cpp | Loading commit data... | |
| test_stl_binders.py | Loading commit data... | |
| test_tagbased_polymorphic.cpp | Loading commit data... | |
| test_tagbased_polymorphic.py | Loading commit data... | |
| test_thread.cpp | Loading commit data... | |
| test_thread.py | Loading commit data... | |
| test_type_caster_pyobject_ptr.cpp | Loading commit data... | |
| test_type_caster_pyobject_ptr.py | Loading commit data... | |
| test_type_caster_std_function_specializations.cpp | Loading commit data... | |
| test_type_caster_std_function_specializations.py | Loading commit data... | |
| test_union.cpp | Loading commit data... | |
| test_union.py | Loading commit data... | |
| test_unnamed_namespace_a.cpp | Loading commit data... | |
| test_unnamed_namespace_a.py | Loading commit data... | |
| test_unnamed_namespace_b.cpp | Loading commit data... | |
| test_unnamed_namespace_b.py | Loading commit data... | |
| test_vector_unique_ptr_member.cpp | Loading commit data... | |
| test_vector_unique_ptr_member.py | Loading commit data... | |
| test_virtual_functions.cpp | Loading commit data... | |
| test_virtual_functions.py | Loading commit data... | |
| test_warnings.cpp | Loading commit data... | |
| test_warnings.py | Loading commit data... | |
| valgrind-numpy-scipy.supp | Loading commit data... | |
| valgrind-python.supp | Loading commit data... |