Repository navigation
Fix parser and env-var inputs that crash or are silently accepted - #369
Open
bernardogv wants to merge 3 commits into
Open
bernardogv wants to merge 3 commits into
bernardogv wants to merge 3 commits into
Conversation
ParseExeType dereferenced endPtr inside `if (!endPtr)` when checking for a bare nearest-NIC executor (`N`). That is a null dereference; at -O3 clang removes the check, so malformed tokens such as `Nx` or `N.1` were silently accepted as a bare `N`. Check `*ptr` as intended. CharToMemType/CharToExeType used strchr on the type string, which also matches the terminating NUL. A token with a rank prefix but no type letter (e.g. `R0`) was therefore accepted with an out-of-range type, and parsing continued past the end of the string. Reject a missing type explicitly and report it as such.
Validation only rejected blockBytes == 0 and blockSize < 0. - Negative blockBytes (e.g. BLOCK_BYTES=-256) passed, corrupted the sub-executor partitioning and produced destination mismatches. - blockSize == 0 passed and, with GFX_SE_TYPE=1, divided by zero in CalculateGridY (SIGFPE).
- GetEnvVar: K/M/G suffixes were applied to an int and overflowed (e.g. BLOCK_BYTES=2G became -2147483648, NIC_CHUNK_BYTES=2G a huge size_t). Parse as 64-bit and reject values that don't fit in an int. - CU_MASK: indices outside 0..63 wrote past the end of the per-XCC mask vector (CU_MASK=0-5000 crashes); negative indices were accepted. - SAMPLING_FACTOR: 0 caused a divide-by-zero on every run; negative values wrapped. Require >= 1. - Print nicChunkBytes (an int) with %d instead of %lu.
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.
Fixes for parser and environment-variable inputs that crash, read out of bounds, or are silently accepted with wrong values. Three commits, independent of #368.
Parser (
167a8d4)Nexecutor token:ParseExeTypedereferencedendPtrinsideif (!endPtr). At-O3clang removes the check, so malformed tokens such asNxandN.1were silently accepted as a bareN. It now checks*ptras intended. A bareNis still accepted.strchralso matches the terminating NUL, so a token likeR0(rank prefix with no type letter) was accepted with an out-of-range type, and parsing continued past the end of the string. It is now rejected with "Missing memory/executor type".Config validation (
2778012)data.blockBytes <= 0andgfx.blockSize <= 0are now rejected. Previously, negativeBLOCK_BYTEScaused destination mismatches, andGFX_BLOCK_SIZE=0withGFX_SE_TYPE=1divided by zero inCalculateGridY.Environment variables (
197f253)GetEnvVar: K/M/G suffixes overflowedint(BLOCK_BYTES=2G→-2147483648). The value is now parsed as 64-bit, and anything that doesn't fit in anintis rejected.CU_MASK: indices outside 0..63 wrote past the end of the per-XCC mask vector, and negative indices were accepted. Both are now rejected.SAMPLING_FACTOR:0divided by zero on every run. It must now be ≥ 1.NIC_CHUNK_BYTESdisplay: theintwas printed with%lu; it now uses%d.Testing
Built with
make TransferBench(-Wall, no warnings) and run on a single-GPU ROCm 7 system, comparingdevelopwith this branch:developdryrun 1M "1 4 (G0 Nx G0)"dryrun 1M "1 4 (G0 N.1 G0)"dryrun 1M "1 4 (G0 R0 G0)"CU_MASK=0-5000CU_MASK=-5SAMPLING_FACTOR=0BLOCK_BYTES=2GBLOCK_BYTES=-256GFX_BLOCK_SIZE=0 GFX_SE_TYPE=1These inputs still behave the same on both builds: a bare
N,CU_MASK=0-3,BLOCK_BYTES=1K,SAMPLING_FACTOR=2, and the default config.