ref: zero-initialize SENTRY_MAKE allocations#1546
Merged
Conversation
58ae155 to
caffdc0
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit caffdc0. Configure here.
caffdc0 to
f02d495
Compare
Introduce sentry__calloc and SENTRY_MAKE_0 to replace the recurring SENTRY_MAKE + memset(ptr, 0, sizeof(T)) pattern across the codebase. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collapse the two allocation macros into one. All SENTRY_MAKE call sites are small control structs where the memset cost is negligible, and zero-init by default eliminates a class of uninitialized-read footguns when struct fields are added later. On the signal-handler path the page allocator already returns zeroed mmap pages, so behavior is unchanged there. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f02d495 to
abc6ffd
Compare
SENTRY_MAKE_0 macro for zero-initialized allocationSENTRY_MAKE allocations
supervacuus
approved these changes
Apr 13, 2026
Collaborator
supervacuus
left a comment
There was a problem hiding this comment.
Thanks! Also, much better than a separate MAKE_0.
mujacica
approved these changes
Apr 13, 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.

After getting bitten by an uninitialized struct member in #1545, I started wondering why not let
callochandle zero-initialization where appropriate. This makesSENTRY_MAKEzero-initialize, allowing the recurringmemsetcalls to be dropped. Less boilerplate, less room for error.Note: The signal-handler path is unchanged. When the page allocator is active, it bump-allocates from
MAP_ANONYMOUSmmap pages that the OS already zeroes on first use, and it never reuses freed allocations, sosentry_mallocandsentry__callocreturn identically zeroed memory on that path.#skip-changelog