fix(legacy): avoid undefined 32-bit shift - #701
Conversation
| @@ -746,7 +750,7 @@ __global__ void __launch_bounds__(((kNumDispatchRDMASenderWarps + 1 + LEGACY_NUM | |||
| if (offset == 0) { | |||
There was a problem hiding this comment.
🔵 suggestion: The MR mixes the functional fix with several formatting-only line-wrapping changes across the file (e.g., notify_dispatch, combine). These appear to come from ./format.sh and are harmless, but bundling unrelated reformatting with a bugfix increases review surface and makes bisecting harder. Consider isolating the functional change from the reformatting in future MRs.
🤖 v3
🤖 ds-review-bot Code Reviewv6The substantive change correctly avoids shifting a 32-bit value by 32 while preserving the intended zero result when the transaction window is full. Other changes are formatting-only. v4v3This MR fixes an undefined-behavior bug in csrc/kernels/legacy/internode.cu where a 32-bit dispatch transaction window ( Files reviewed: 1 |
Summary
Why
When
window == 0xffffffffu,num_empty_slotsis 32. Shifting a32-bit value by its width is undefined behavior in C++, so the compiler is
not required to produce the intended zero value. If the bitmap is not
cleared, the dispatch transaction window can retain stale completion state.
The full-window case has no remaining pending bits, so assigning zero is the
direct representation of the intended state. Other shift counts retain the
existing behavior.
Fixes #366.
Validation
shift exponent 32 is too large0ufor the full-window casebash ./format.shgit diff --check upstream/main...HEADformat.shalso reformats several pre-existing long lines in the samelegacy source file; the only behavioral change is the transaction-window
assignment.