Skip to content

Initialize Standard JSON device padding and sentinels#15

Merged
ashkanvg merged 1 commit into
masterfrom
fix/issue-3-standard-padding-sentinel-init
Jul 24, 2026
Merged

Initialize Standard JSON device padding and sentinels#15
ashkanvg merged 1 commit into
masterfrom
fix/issue-3-standard-padding-sentinel-init

Conversation

@ashkanvg

Copy link
Copy Markdown
Collaborator

Fixes #3

Root cause

The reported initcheck finding and the returned-result gap are two distinct uninitialized regions:

  • depth_init_MathAPI reads packed 32-bit words from out_string_open_close_8_GPU. When the open/close count is not divisible by four, the allocation contains 1-3 tail bytes that removeCopy never writes.
  • The returned pinned host layout reserves one overlapping slot for structural[last] and pair_pos[0], but that synthetic root/closing sentinel was not initialized until iterator construction.

The host result buffer is allocated only after depth_init_MathAPI and CUB sorting complete, so initializing that host buffer alone cannot resolve the earlier device read.

Fix

  • Zero only the 1-3 device padding bytes before removeCopy and depth_init_MathAPI.
  • Initialize structural[0] and the overlapping structural[last] / pair_pos[0] sentinel before returning.
  • Preserve all allocations, copy destinations, pair-array offsets, kernels, and public layout.
  • Avoid a full pinned-buffer memset.

Validation

Environment: NVIDIA A100 80GB PCIe (sm_80), driver 580.173.02, CUDA 13.3, Compute Sanitizer 2026.2.1.

  • depth_init_MathAPI initcheck findings by tail padding: padding 0: 0 -> 0; padding 1: 1 -> 0; padding 2: 1 -> 0; padding 3: 1 -> 0.
  • CUB internal tuple<uint32_t,uint8_t> padding diagnostics remain unchanged (3 x open_close_count) and are independent of the application tail/sentinel storage.
  • Pre-iterator sample sentinels: baseline SLAST=0, P0=0; fixed SLAST=22389, P0=22389; overlap verified.
  • Valid inputs: 80/80 successful; malformed padding-1/3 inputs: 40/40 rejected with zero false passes.
  • Sample output unchanged: 22,390 elements and lang=en.
  • Full twitter_large_record.json output unchanged: 61,072,730 elements and lang=en.
  • Full real-data hashes unchanged: structural hash 2211520110405220824; 4,676,467 opening pairs; opening-pair hash 8222789647060382053.
  • GPU SASS and resource hashes are identical.
  • Performance, 5 warmups + 30 interleaved pairs on the 804 MiB dataset: baseline median 337.144 ms; fixed median 339.667 ms (+0.748%, within run-to-run noise).

The change is limited to five lines in cujson/parse_standard_json.cu.

@ashkanvg
ashkanvg merged commit ea71b66 into master Jul 24, 2026
@ashkanvg
ashkanvg deleted the fix/issue-3-standard-padding-sentinel-init branch July 24, 2026 23:58
@ashkanvg ashkanvg self-assigned this Jul 25, 2026
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.

Uninitialized memory read in depth_init_MathAPI from pair_pos buffer off-by-one

1 participant