Title: Avoid unchecked list indexing in JSON encoder by youknowdot · Pull Request #9431 · RustPython/RustPython · GitHub
Open Graph Title: Avoid unchecked list indexing in JSON encoder by youknowdot · Pull Request #9431 · RustPython/RustPython
X Title: Avoid unchecked list indexing in JSON encoder by youknowdot · Pull Request #9431 · RustPython/RustPython
Description: Summary The native JSON list encoder checks the live length and fetches an item under separate list guards. A concurrent shrink can invalidate the index between those operations. Use a checked, cloned item lookup under one read guard. If the item disappeared, stop before emitting a separator and finish through the existing marker-cleanup path. The guard is released before recursive encoding or Python callbacks. This preserves live callback-deletion semantics rather than taking a whole-list snapshot. Only crates/stdlib/src/json.rs changes. No Lib assertions, skips, dependency pins, or pending free-threading-package files are changed. Validation Focused CLI/VM/stdlib cargo check and strict Clippy (-D warnings) passed. Repository hooks passed, including rustfmt and cspell. Bounded executable build passed; all five selected existing JSON tests passed (0 skips). Local validation used main 3b0dd785; the encoder source is unchanged in current main, and current-main integration awaits CI. The selected tests check the native encoder, ten-item callback deletion, small circular-reference/marker cleanup cases, and indentation. They are not a concurrent-race or general free-threading compatibility claim. Full workspace, C-API, concurrency stress, and GC/UAF-specific regressions were not run locally; hosted CI remains pending. AI assistance OpenAI Codex assisted with the implementation, CPython source comparison, validation, and this pull request description; the model version is unavailable. Summary by CodeRabbit Bug Fixes JSON encoding now stops safely if a sequence changes size during encoding, instead of attempting to access an unavailable element.
Open Graph Description: Summary The native JSON list encoder checks the live length and fetches an item under separate list guards. A concurrent shrink can invalidate the index between those operations. Use a checked, clo...
X Description: Summary The native JSON list encoder checks the live length and fetches an item under separate list guards. A concurrent shrink can invalidate the index between those operations. Use a checked, clo...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9431
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:c8f5c67c-22fb-0804-b2e1-bd7543d16055 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BD08:1FAE:BFEE04:102E2B2:6B01FA73 |
| html-safe-nonce | ee55072e99303a8fb9e7eea107b5073753974f4bea5c06469c5c554eb2d05a42 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDA4OjFGQUU6QkZFRTA0OjEwMkUyQjI6NkIwMUZBNzMiLCJ2aXNpdG9yX2lkIjoiNTY0MzIwMTQ0Mzc1NTMyNjA2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ac43bd86e5b260d70f93f9539010505b7bd482000a0300235cdbac30ffbc356e |
| hovercard-subject-tag | pull_request:5051167746 |
| 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/9431/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 The native JSON list encoder checks the live length and fetches an item under separate list guards. A concurrent shrink can invalidate the index between those operations. Use a checked, clo... |
| 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 | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width