-
Notifications
You must be signed in to change notification settings - Fork 123
Add defensive code to check buddy allocator. #834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,10 @@ namespace snmalloc | |||||||||||
| // All RBtrees at or above this index should be empty. | ||||||||||||
| size_t empty_at_or_above{0}; | ||||||||||||
|
|
||||||||||||
| // Tracks the total memory (in bytes) held by this buddy allocator, | ||||||||||||
| // updated at the API boundary. Debug builds only. | ||||||||||||
|
Comment on lines
+30
to
+31
|
||||||||||||
| // Tracks the total memory (in bytes) held by this buddy allocator, | |
| // updated at the API boundary. Debug builds only. | |
| // Tracks the total memory (in bytes) currently represented by this | |
| // buddy allocator's free structures (caches and trees). Used for | |
| // debug-only consistency checks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug_buddy_totalis updated unconditionally inadd_block/remove_block, so it will add extra writes and enlargeBuddyeven in release builds, despite the comment saying "Debug builds only". Consider making this member and its updates debug-only (e.g., wrap the field and the +=/-= sites in#ifndef NDEBUGorif constexpr (Debug)), so there’s no runtime/size overhead in production builds.