Skip to content

fix: address critical and important review findings#2

Merged
membphis merged 1 commit into
mainfrom
worktree-fix-review-findings
May 15, 2026
Merged

fix: address critical and important review findings#2
membphis merged 1 commit into
mainfrom
worktree-fix-review-findings

Conversation

@membphis
Copy link
Copy Markdown
Collaborator

Summary

  • Critical: wrap Document.scratch in RefCell to eliminate &Document + &mut scratch aliasing UB in qjd_get_str / qjd_cursor_get_str; runtime-guard the 5 AVX2 unit tests so cargo test no longer SIGILLs on non-AVX2 hosts.
  • Important: add avx2 Cargo feature (default-on) + CI step for --no-default-features; rename misleading qjd_cursor.cache_slot to _reserved0/1; store child_ends in SkipSlot so cache-hit lookups skip find_value_span (spec §6.3); reuse module-level cur_box in Lua Cursor:open/field/index; update README status; add §9.2 tests (5K-key wide object, i64/f64 boundaries, Lua Doc GC).
  • Minor: clean up dead-code attributes; fix spec module-layout diagram; note missing bench fixtures in README Roadmap.

Test plan

  • `cargo test --release` — 101 tests pass
  • `cargo test --release --no-default-features` — 96 tests pass (scalar-only path)
  • `cargo build --release` — `libquickdecode.so` exposes all `qjd_*` symbols
  • Lua busted suite (runs in CI; LuaJIT/busted not available locally)

Critical:
- Wrap Document.scratch in RefCell<Vec<u8>> so qjd_get_str /
  qjd_cursor_get_str no longer alias &Document with &mut scratch
  (Stacked Borrows UB; Miri would flag).
- Guard the 5 unit tests in src/scan/avx2.rs with a runtime
  is_x86_feature_detected check so `cargo test` does not SIGILL on
  x86_64 hosts without AVX2/PCLMUL.

Important:
- Add `avx2` Cargo feature (default-on); gate the AVX2 module,
  dispatcher and proptest behind it so `cargo test --no-default-features`
  exercises the scalar-only path per spec §9.4. CI runs both.
- Rename qjd_cursor.cache_slot / _pad to _reserved0 / _reserved1 in
  the Rust struct, C header, Lua cdef and spec — the slot is never
  read in v1, so the old name misled C consumers.
- Store child_ends alongside child_starts in SkipSlot so the cache-hit
  path in resolve_in_known_children skips find_value_span entirely,
  matching spec §6.3 "no brace counting".
- Reuse the module-level cur_box in Lua Cursor:open/field/index
  instead of ffi.new("qjd_cursor[1]") per call — keeps LuaJIT traces
  intact on the hot path.
- Update README "Status" to reflect the shipped implementation.
- Add spec §9.2 coverage: 5K-key wide object cache test, i64::MAX/MIN
  and 1.7e308 boundaries, i64-overflow at 2^63, float-form rejection
  for get_i64, Lua Doc GC finalizer test.

Minor:
- Drop unused #[allow(dead_code)] attributes; mark test-only
  SkipCache::len with #[cfg(test)].
- Fix spec module-layout diagram to match the actual tree (no
  runtime_dispatch.rs; cursor.rs / path.rs / error.rs exist).
- Note missing large_dump.json / deep_nest.json bench fixtures in
  README Roadmap.
@membphis membphis merged commit 3cf747d into main May 15, 2026
2 checks passed
@membphis membphis deleted the worktree-fix-review-findings branch May 15, 2026 15:12
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