Title: Fix bytearray membership racing with resizing by youknowdot · Pull Request #9091 · RustPython/RustPython · GitHub
Open Graph Title: Fix bytearray membership racing with resizing by youknowdot · Pull Request #9091 · RustPython/RustPython
X Title: Fix bytearray membership racing with resizing by youknowdot · Pull Request #9091 · RustPython/RustPython
Description: Summary Avoid synthetic buffer exports when bytearray membership uses an exact bytes, int, or bool needle. These needles cannot run Python while being prepared, so the existing read lock is sufficient to serialize the search with resizing. This addresses the intermittent macOS test_free_threading_bytearray failure seen in #9063: one worker's b'\xdd' not in a temporarily exported a, making another worker's a[:] = c raise BufferError after c changed length. CPython protects its temporary export with an object critical section; the previous RustPython path exposed that temporary export to concurrent assignments. Generic index/buffer callbacks, subclasses, and real memoryview exports keep their existing protection. This is scoped to exact bytes/int/bool membership, not a general critical-section implementation. Add deterministic Python regression coverage in the existing builtin_bytearray.py snippet for membership results, integer range checks, self-containment, bytes-subclass index dispatch, reentrant callbacks, real exports, same-size mutation, and export cleanup. Lib is unchanged. Validation Initial fix (375501d6): Release build and strict workspace/all-targets plus separate CAPI/all-targets Clippy passed with -D warnings. The deterministic Python contract passed on RustPython and final CPython 3.15; the three selected upstream containment/reentrancy tests passed on RustPython. One bounded concurrent run passed on free-threading RustPython. The CPython reference run also passed, but that oracle has the GIL enabled. Workspace test-binary compilation (cargo test --workspace --exclude rustpython_wasm --exclude rustpython-venvlauncher --exclude rustpython-capi --no-run) passed, producing 22 executables without running them. GitHub CI passed: 14 jobs passed, 2 configured skips; CodSpeed passed. Review follow-up (b373af16e): Exact builtin bool uses the callback-free integer path; regression coverage is consolidated into builtin_bytearray.py. Fresh release build and strict workspace/all-targets plus separate CAPI/all-targets Clippy passed with -D warnings. The isolated finite regression function, including True/False cases, passed once on the fresh RustPython binary and once on final CPython 3.15. The concurrent fixture and upstream selectors were not rerun for this follow-up. Its CI is tracked separately. Full local workspace runtime tests, the full snippets suite, and the full test_bytes module have not been run. Separate CAPI test-binary compilation has not been run. This is targeted local validation, not a claim that all local tests pass. The fixed concurrent fixture is retained as external evidence rather than a deadline-sensitive CI snippet. It has three workers, 512 rounds each, at most 16 KiB target storage, and an external process watchdog. A passing run is probabilistic evidence, not proof of absence of races. AI assistance Codex/OpenAI performed source diagnosis, implemented the patch and Python regression checks, independently reviewed the lock/callback contract, and ran the reported validation. The runtime did not expose an exact model version. Summary by CodeRabbit Bug Fixes Improved bytearray containment checks for byte strings, integers, and booleans, including correct handling of out-of-range integers. Preserved resizing restrictions while a memoryview or buffer operation is active, with resizing available again after the buffer is released.
Open Graph Description: Summary Avoid synthetic buffer exports when bytearray membership uses an exact bytes, int, or bool needle. These needles cannot run Python while being prepared, so the existing read lock is suffici...
X Description: Summary Avoid synthetic buffer exports when bytearray membership uses an exact bytes, int, or bool needle. These needles cannot run Python while being prepared, so the existing read lock is suffici...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9091
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:1dc87a73-576f-3d1d-1c9d-194f7f1861a4 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BB72:2DBB21:357EFB9:475CBDF:6B020928 |
| html-safe-nonce | c9fe566e6de38a58d13319d2195c63fbab4b9ae075b1c2f01e8c4ce705db232b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjcyOjJEQkIyMTozNTdFRkI5OjQ3NUNCREY6NkIwMjA5MjgiLCJ2aXNpdG9yX2lkIjoiNDU3ODA2NDExNDI4NjQ2MzI3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8eb9adc600c9d563476afcb720201c0ec65ed07fecbbe2259938a057e55a23e8 |
| hovercard-subject-tag | pull_request:4838043768 |
| 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/9091/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 Avoid synthetic buffer exports when bytearray membership uses an exact bytes, int, or bool needle. These needles cannot run Python while being prepared, so the existing read lock is suffici... |
| 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 full-width |
| 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 | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width