Repository navigation
Fix libmisc queue tail deletion and unsigned 32-bit decoding - #87
Merged
tlindner merged 1 commit intoOct 29, 2026
Merged
Conversation
qDeleteNode stopped its search when the current node had no successor, so the last node in a multi-node queue was never checked. Deleting that node incorrectly returned failure and left it linked in the queue. Continue the search while the current node exists so the tail can be unlinked and its data and node allocations released. int4 shifted the first input byte as a signed int before casting the completed result to unsigned int. For a leading byte of 0x80 or greater, the 24-bit left shift cannot be represented in a signed 32-bit int and invokes undefined behavior. Convert the first byte to unsigned int before shifting, keeping the resulting addition unsigned as well. Add a libmisctest executable using the existing TinyTest framework and integrate it into the Unix test and clean targets. Ignore its generated binary alongside the other unit-test executables. Cover queue deletion at the tail, head, middle, and only node, checking the remaining sequence and termination. Cover int4 decoding of zero, a mixed-byte value, the signed boundary, high-bit mixed bytes, and the maximum 32-bit value. Validation: - The tail-deletion regression failed before its fix; the other three queue deletion tests passed. - UndefinedBehaviorSanitizer rejected the original int4 implementation when decoding 0x80000000 and passed all five libmisc tests after the fix. - make -C build/unix completed successfully with all 59 tests passing. - git diff --check passed.
DrPitre
approved these changes
Oct 28, 2026
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.
qDeleteNode stopped its search when the current node had no successor, so the last node in a multi-node queue was never checked. Deleting that node incorrectly returned failure and left it linked in the queue. Continue the search while the current node exists so the tail can be unlinked and its data and node allocations released.
int4 shifted the first input byte as a signed int before casting the completed result to unsigned int. For a leading byte of 0x80 or greater, the 24-bit left shift cannot be represented in a signed 32-bit int and invokes undefined behavior. Convert the first byte to unsigned int before shifting, keeping the resulting addition unsigned as well.
Add a libmisctest executable using the existing TinyTest framework and integrate it into the Unix test and clean targets. Ignore its generated binary alongside the other unit-test executables. Cover queue deletion at the tail, head, middle, and only node, checking the remaining sequence and termination. Cover int4 decoding of zero, a mixed-byte value, the signed boundary, high-bit mixed bytes, and the maximum 32-bit value.
Validation: