* 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 |
|---|---|---|
| .github | Loading commit data... | |
| docs | Loading commit data... | |
| include/pybind11 | Loading commit data... | |
| pybind11 | Loading commit data... | |
| tests | Loading commit data... | |
| tools | Loading commit data... | |
| .appveyor.yml | Loading commit data... | |
| .clang-format | Loading commit data... | |
| .clang-tidy | Loading commit data... | |
| .cmake-format.yaml | Loading commit data... | |
| .codespell-ignore-lines | Loading commit data... | |
| .gitattributes | Loading commit data... | |
| .gitignore | Loading commit data... | |
| .pre-commit-config.yaml | Loading commit data... | |
| .readthedocs.yml | Loading commit data... | |
| CMakeLists.txt | Loading commit data... | |
| LICENSE | Loading commit data... | |
| MANIFEST.in | Loading commit data... | |
| README.rst | Loading commit data... | |
| SECURITY.md | Loading commit data... | |
| noxfile.py | Loading commit data... | |
| pyproject.toml | Loading commit data... | |
| setup.cfg | Loading commit data... | |
| setup.py | Loading commit data... |