Title: Prevent array.fromfile reentrancy deadlock in append conversion by Copilot · Pull Request #6576 · RustPython/RustPython · GitHub
Open Graph Title: Prevent array.fromfile reentrancy deadlock in append conversion by Copilot · Pull Request #6576 · RustPython/RustPython
X Title: Prevent array.fromfile reentrancy deadlock in append conversion by Copilot · Pull Request #6576 · RustPython/RustPython
Description: array.fromfile could deadlock when __index__ invoked during element conversion performed a nested append on the same array.
Append conversion before locking: Convert elements (capturing array kind) prior to acquiring the write lock, then push with a runtime invariant check to avoid reentrant deadlocks.
Stronger invariants: Added typed helpers (ArrayType/ArrayElementValue) with assertive mismatch diagnostics to catch unexpected kind/value divergence.
Regression coverage: Extended extra_tests/snippets/stdlib_array.py with a reentrancy scenario where fromfile triggers __index__ that re-appends to the same array.
Example:
import array
a = array.array("b")
class X:
def __index__(self):
a.append(0) # reenters append while fromfile is mid-conversion
return 0
class R:
def read(self, n):
a.append(X())
return b"\0" * n
a.fromfile(R(), 1) # no deadlock; contents now [0, 0, 0]
Original prompt
This section details on the original issue you should resolve
Open Graph Description: array.fromfile could deadlock when __index__ invoked during element conversion performed a nested append on the same array. Append conversion before locking: Convert elements (capturing array kind...
X Description: array.fromfile could deadlock when __index__ invoked during element conversion performed a nested append on the same array. Append conversion before locking: Convert elements (capturing array kind...
Opengraph URL: https://github.com/RustPython/RustPython/pull/6576
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:158f9ae1-62b8-c55d-e5d6-de1568e4cdb4 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | DF4A:2D14CF:30CA7F:437EA9:6970A6D0 |
| html-safe-nonce | 9befa39713413968e61ef039f5cb9204f08b2ce3bb235b86c5a263bd4db44849 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjRBOjJEMTRDRjozMENBN0Y6NDM3RUE5OjY5NzBBNkQwIiwidmlzaXRvcl9pZCI6IjUzMzc1MDk1OTQ1Njc1ODM0NDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | efe3a0d359f35753a315f170a72b3b0dda5227c2fb23d8c61e9454fb3567b9b6 |
| hovercard-subject-tag | pull_request:3134404281 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,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/6576/checks |
| twitter:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| og:image:alt | array.fromfile could deadlock when __index__ invoked during element conversion performed a nested append on the same array. Append conversion before locking: Convert elements (capturing array kind... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b06a4c45c45fd0bb038b3759265ea6e38211f45d18130bc65261990be6b5972a |
| turbo-cache-control | no-preview |
| 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 full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0e1c4964831785bd64cb22d82e7cf2391ae01f45 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width