Skip to content

fix(mysql2): fold the JSON array arm so no local spans a nested conversion - #9352

Merged
proggeramlug merged 2 commits into
mainfrom
fix/9350-fold
Sep 1, 2026
Merged

fix(mysql2): fold the JSON array arm so no local spans a nested conversion#9352
proggeramlug merged 2 commits into
mainfrom
fix/9350-fold

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Follow-up to #9350, which takes perry-ext-mysql2 to 10 unrooted-local findings against its ceiling of 9.

The new json_value_to_jsvalue decoder recurses, and its array arm was:

arr = unsafe { js_array_push(arr, json_value_to_jsvalue(item)) };

Rust evaluates arr before the recursive call, and that call allocates — so a collection inside it leaves the already-read pointer stale. That is the #8217 shape rather than a checker artifact, and the recursion makes it likelier to actually happen than in the flat row builders.

Folding removes the named local, which is what the row and field builders alongside it already do, and returns the file to its ceiling with no baseline change.

Worth saying plainly: this reduces the window, it does not eliminate the exposure. perry-ext-mysql2 deliberately depends on perry-ffi only — perry-runtime is a dev-dependency, so there is no RuntimeHandleScope available in its production code — and building any nested JS structure without roots keeps a live JS pointer across allocations somewhere. Every builder in this crate has that property today and is carried as accepted debt. The fold matches existing practice; it is not a claim that the crate is rooting-safe. Giving these builders real roots would need the crate to take a perry-runtime dependency, which is a design decision beyond this fix.

Validation: perry-runtime --lib 2905/0 and perry-ext-mysql2 green under RUST_TEST_THREADS=1; release build clean with no warnings; file-size, raw-handle, unrooted-local (--check, --self-test, --no-raise-vs), root-holder, shape-census and fmt gates all pass with no baseline touched.

Ralph Küpper added 2 commits September 1, 2026 05:38
…rsion

json_value_to_jsvalue recurses, so the array pointer was read as an argument
before a call that can allocate and move it. The fold keeps the file at its
unrooted-local ceiling of 9.
@proggeramlug
proggeramlug merged commit 26c345d into main Sep 1, 2026
17 checks passed
@proggeramlug
proggeramlug deleted the fix/9350-fold branch September 1, 2026 03:39
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