Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cl testing #90

Closed
wants to merge 1 commit into from
Closed

cl testing #90

wants to merge 1 commit into from

Conversation

rwgk
Copy link
Contributor

@rwgk rwgk commented Feb 5, 2024

Helper/scratch PR for testing.

rwgk pushed a commit that referenced this pull request Feb 5, 2024
…ges.

In order of importance:

* Bug fix (moderately important): Missing `Py_DECREF(type_self)` in `tp_dealloc_impl`.

  * This bug was triggered with the upgrade to Python to 3.9. It was discovered coincidentally when adding the new `testDerivedTpInitRegistryWeakrefBasedCleanup` (see below). When running the test in a `while True` loop, the Resident Memory Size (`RES` in `top`) exceeded 1 GB after just a few seconds.

  * Root cause: python/cpython#79991

  * Critical clue leading to the fix: https://github.com/pybind/pybind11/blob/768cebe17e65c2a0a64ed067510729efc3c7ff6c/include/pybind11/detail/class.h#L467-L469

* Bug fix (very minor): Incorrect `Py_DECREF(self)` in `tp_init_with_safety_checks`.

  * This bug was introduced with cl/559501787. The `Py_DECREF(self)` was accidentally adopted along with the corresponding pybind11 error message (see link in description of cl/559501787). It was discovered coincidentally by MSAN (heap use after free) while testing [google/pybind11clif#30095](google/pybind11clif#30095).

  * After inspecting https://github.com/python/cpython/blob/b833b00482234cb0f949e6c277ee1bce1a2cbb85/Objects/typeobject.c#L1103-L1106 it became clear that the `Py_DECREF(self)` is indeed incorrect in this situation (it is correct in the original pybind11 sources).

* The weakref-based cleanup added in [google/pybind11clif#30095](google/pybind11clif#30095) is ported back to PyCLIF. — This was the original purpose of this CL.

* `tp_init_intercepted` is renamed to `tp_init_with_safety_checks` for for compatibility with google/pybind11clif#30095.

GitHub testing: #90

PiperOrigin-RevId: 604337502
@rwgk
Copy link
Contributor Author

rwgk commented Feb 5, 2024

main @ 78c83cf

@rwgk rwgk closed this Feb 5, 2024
@rwgk rwgk deleted the cl_testing branch February 5, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant