Title: Release PickleBuffer outside its lock by youknowdot · Pull Request #9587 · RustPython/RustPython · GitHub
Open Graph Title: Release PickleBuffer outside its lock by youknowdot · Pull Request #9587 · RustPython/RustPython
X Title: Release PickleBuffer outside its lock by youknowdot · Pull Request #9587 · RustPython/RustPython
Description: Summary Detach the owned PyBuffer while holding the PickleBuffer write lock, then drop it after releasing the lock. Dropping its final share can invoke a Python __release_buffer__ hook; a hook that reenters the same PickleBuffer would otherwise try to acquire the held lock and deadlock. Existing shares cloned before release remain alive, and a concurrent access after the take observes the released state. The change does not address the separate PickleBuffer GC-traversal expected failure. Behavior difference This is a narrow deadlock fix, not exact CPython callback-state parity. CPython 3.15's PyBuffer_Release invokes the exporter hook before clearing view.obj. This change publishes the released state first, so a reentrant raw() or buffer acquisition observes a released PickleBuffer and another release() is inert. Reconstructing a usable acquisition during the callback is not known to be safe with RustPython's final-share release latch and would need separate ownership work. Validation Independently source-reviewed for last-share release, reentrancy, and concurrent get/release ordering. prek run --files crates/stdlib/src/pickle.rs, normal commit hooks and git diff --check passed. Native RustPython compilation and execution were not run locally; hosted CI is required. Existing test_picklebuffer.test_release covers basic release and idempotency, but no existing test identified directly exercises release-hook reentrancy. That behavior remains an execution-coverage gap. Summary by CodeRabbit Bug Fixes Buffer release now completes its state update before cleanup callbacks run, helping avoid interference between buffer cleanup and other operations. The buffer is marked as released before its final cleanup, so subsequent operations can observe the updated state even while cleanup is in progress.
Open Graph Description: Summary Detach the owned PyBuffer while holding the PickleBuffer write lock, then drop it after releasing the lock. Dropping its final share can invoke a Python __release_buffer__ hook; a hook that...
X Description: Summary Detach the owned PyBuffer while holding the PickleBuffer write lock, then drop it after releasing the lock. Dropping its final share can invoke a Python __release_buffer__ hook; a hook that...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9587
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:cd4e8eff-fb6d-2068-b6dc-0b5e2b599594 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CA26:3CBB3E:2C8D84D:38E69B7:6B01F9A3 |
| html-safe-nonce | db308297e1bc3d13508e78f68e42c8dc8feb931771add32f840b204d9875c3c9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTI2OjNDQkIzRToyQzhEODREOjM4RTY5Qjc6NkIwMUY5QTMiLCJ2aXNpdG9yX2lkIjoiNzM2MTAxMzE0MDM3NDU1MDk0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a0d331fe2af2c466d3d39237cabbfd92234483783e14c30f7372bb9cb2e56baf |
| hovercard-subject-tag | pull_request:5136781450 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9587/files |
| twitter:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| og:image:alt | Summary Detach the owned PyBuffer while holding the PickleBuffer write lock, then drop it after releasing the lock. Dropping its final share can invoke a Python __release_buffer__ hook; a hook that... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width