chore: Add debug assertions before unsafe code blocks#3655
Merged
andygrove merged 1 commit intoapache:mainfrom Mar 10, 2026
Merged
chore: Add debug assertions before unsafe code blocks#3655andygrove merged 1 commit intoapache:mainfrom
andygrove merged 1 commit intoapache:mainfrom
Conversation
Add debug_assert! statements between SAFETY comments and unsafe blocks to catch precondition violations during development and testing. Assertions cover: - Null pointer checks before raw pointer dereference - Index bounds checks before array/bitset access - Initialization checks before accessing global singletons - Alignment checks before aligned pointer writes - Non-negative size/length checks before slice construction
b7a72e7 to
1ce1de7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
debug_assert!statements between SAFETY comments andunsafeblocks throughout the native Rust codeFiles changed
native/core/src/execution/shuffle/spark_unsafe/row.rs— pointer null checks on all accessor methods, row initialization checks, loop bounds checksnative/core/src/execution/shuffle/spark_unsafe/list.rs— address validity and index bounds checksnative/core/src/execution/shuffle/spark_unsafe/map.rs— address and size validity checksnative/core/src/execution/jni_api.rs— address, size, and alignment checks for sort partitionnative/core/src/execution/utils.rs— pointer alignment checks before aligned writesnative/core/src/jvm_bridge/mod.rs— initialization checks beforeget_unchecked()calls