[REBASE & FF] patina_debugger: Fix use of crate without "alloc" and fix associated issues#1331
Merged
Javagedes merged 2 commits intoOpenDevicePartnership:mainfrom Feb 24, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
makubacki
reviewed
Feb 20, 2026
f00f72b to
9af70e8
Compare
makubacki
approved these changes
Feb 23, 2026
5d87fd1 to
da05ff0
Compare
Currently the alloc feature attempts to prevent use of the alloc features but does not actually remove the use of the alloc crate. This means that it is quite easy to accidentally use the alloc crate and break this use case. Additionally, it makes it too easy to accidentally add heap allocations where they shouldn't be, such as by using `format!` in a monitor command. This feature also helps increase awareness of when heap allocations are used which is important for the debugger which runs in limited environments. The commit removes use of the `alloc` crate when the `alloc` feature is not enabled, and removes all code leveraging it.
In all cases, the GDB stub is transitioned though a constant reference and pointer before being converted back to a mutable reference for use. This can cause unexpected behavior with the compilers interpretting the type as immutable. When the `alloc` feature is disabled, the debugger uses a static buffer for the GDB stub. This buffer current defines the buffer simple as a const array of `u8`. However, the GDB stub converts this to a mutable reference leading to undefined behavior, and active causes faults if the stub is placed in a read-only section by the linker. This commit stores the GDB buffer as a NonNull pointer in the mutable internal struct, and prevents use of any const pointer to the memory. When the `alloc` feature is disabled, the static buffer the static buffer is now wrapped in an UnsafeCell to allow for interior mutability ensuring the compiler knows the memory should be treated as mutable.
Contributor
|
@codecov re-run |
os-d
approved these changes
Feb 24, 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.
Description
Currently the alloc feature attempts to prevent use of the alloc features but does not actually remove the use of the alloc crate. This means that it is quite easy to accidentally use the alloc crate and break this use case.
Additionally, it makes it too easy to accidentally add heap allocations where they shouldn't be, such as by using
format!in a monitor command. This feature also helps increase awareness of when heap allocations are used which is important for the debugger which runs in limited environments.The commit removes use of the
alloccrate when theallocfeature is not enabled, and removes all code leveraging it.Issue #1318
How This Was Tested
Tested on local build and Q35
Integration Instructions
N/A