Skip to content

[Bug] Fix DLPack field offset truncation and two allocator bugs.#768

Open
duburcqa wants to merge 4 commits into
mainfrom
duburcqa/fix_dlpack_field_offset_truncation
Open

[Bug] Fix DLPack field offset truncation and two allocator bugs.#768
duburcqa wants to merge 4 commits into
mainfrom
duburcqa/fix_dlpack_field_offset_truncation

Conversation

@duburcqa

@duburcqa duburcqa commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Issue: N/A

Brief Summary

copilot:summary

Three host-side memory-safety fixes, found while root-causing a Genesis simulation NaN that appeared once a SNode tree grew past 2 GiB:

  • DLPack export truncated in-tree field byte offsets to signed int (field_to_dlpack). For a field placed past 2^31 bytes in its tree, the wrapped offset failed the >= 0 guard and was silently dropped, so the exported view aliased the tree base: reads returned unrelated fields and writes corrupted them. Fixed by keeping the offset size_t/uint64_t end to end (DLTensor::byte_offset is uint64_t). Regression test: test_dlpack_field_offset_past_2gib (marked slow + run_in_serial, 2.24 GB allocation), verified to fail before the fix and pass after.
  • UnifiedAllocator overstated the chunk tail (tail = data + size + allocation_size instead of data + allocation_size), so a follow-up allocation could be handed an address past the real end of the mmap'd chunk. Regression test added in host_memory_pool_test.cpp.
  • CachingAllocator::allocate dereferenced an erased iterator (it_blk->second after mem_blocks_.erase(it_blk)); erase order swapped.

Walkthrough

copilot:walkthrough

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

@duburcqa duburcqa changed the title [Bug] Fix DLPack field offset truncation and two allocator bugs [Bug] Fix DLPack field offset truncation and two allocator bugs. Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

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