Repository navigation
Check the in-use allocator count after the loop in debug_in_use - #903
Merged
Matthew Parkinson (mjp41) merged 1 commit intoNov 13, 2026
Merged
Conversation
debug_in_use(count) checked "count != 0" inside the loop over the allocator pool, right after the first allocator. Any call with count > 0 therefore failed with "two few allocators in use" unless the first allocator in the pool was the only one in use: debug_in_use(2) always failed, and with count > 0 an empty pool was not reported at all. Move the check after the loop so the count is compared once every allocator has been visited. The in-tree callers only pass 0, which behaves as before. func/teardown now calls debug_in_use with one and two scoped allocators held.
Matthew Parkinson (mjp41)
approved these changes
Nov 13, 2026
Matthew Parkinson (mjp41)
left a comment
Member
There was a problem hiding this comment.
LGTM, thank for fixing
Matthew Parkinson (mjp41)
enabled auto-merge (squash)
November 13, 2026 13:27
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 #902
debug_in_use(count)comparedcountwith 0 inside the loop over the allocator pool, right after the first allocator. Any call withcount > 0therefore failed with "two few allocators in use" unless the first allocator in the pool was the only one in use.debug_in_use(2)always failed, and withcount > 0an empty pool was not reported.Changes:
src/snmalloc/global/globalalloc.h: move thecount != 0check after the loop. Callers that pass 0, which are all the in-tree callers, behave as before.src/test/func/teardown/teardown.cc: addcheck_debug_in_use(), which holds one and then two scoped allocators and callsdebug_in_usewith 1, 2, 1 and 0.Testing (Debug builds,
ctest -R):func-teardown-fastandfunc-teardown-checkfail onmainwith the new test ("Error: two few allocators in use.") and pass with the change.func-{teardown,first_operation}-{fast,check}, 4/4 passed.func-{teardown,first_operation,malloc,new}-{fast,check}, 8/8 passed.The "two few" typo in the message is left as is.
This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.