gdb/amdgpu-tdep: Fix assertion in amdgpu_segment_address_to_core_address#146
Merged
Merged
Conversation
lumachad
reviewed
May 29, 2026
Collaborator
lumachad
left a comment
There was a problem hiding this comment.
A few comments. Otherwise LGTM if CI is good.
cfaf837 to
c0d1870
Compare
Collaborator
Author
|
Addressed comments, thanks (and sorry for the typos). |
lumachad
approved these changes
May 29, 2026
Collaborator
lumachad
left a comment
There was a problem hiding this comment.
Leaving an approval from my side.
c0d1870 to
ddfc21e
Compare
aktemur
reviewed
May 29, 2026
aktemur
approved these changes
May 29, 2026
ddfc21e to
cf38b6f
Compare
The code in amdgpu_segment_address_to_core_address was assuming that it
could not receive an address which had bits already set in the bits
where it wants to store the address space ID. This is an invalid
assumption, as a user input can forge any address that gets into this
function.
I stumbled onto the issue while looking at something else. I wanted to
inspect a wave's stack, but used the wrong register for the stack
pointer, which ended up causing the assertion to trigger:
(gdb) x/32x private_wave#$s32
../../gdb/amdgpu-tdep.c:1488: internal-error: amdgpu_segment_address_to_core_address: Assertion `(significant_bits & address) == address' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
This triggered the invalid expectation in
amdgpu_segment_address_to_core_address. Because this is expressed as an
assertion rather than a test triggering an error, this is not handled
gracefully.
This patch fixes this by changing the assert into a "if (invalid_pred)
errer (_(msg))" to gracefully handle invalid input. While at it, the
patch also improved on the check to ensure that canonical addresses
(where the address is sign-extended past the significant bits).
This also adds a test that exercises consuming invalid input as well as
consuming sign extended addresses.
Change-Id: I3281f68b65eb817e949378f5548169c95cbf277c
cf38b6f to
70dce2c
Compare
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.
The code in amdgpu_segment_address_to_core_address was assuming that it could not receive an address which had bits already set in the bits where it wants to store the address space ID. This is an invalid assumption, as a user input can forge any address that gets into this function.
I stumbled onto the issue while looking at sometging else. I wanted to inspect a wave's stack, but used the wrong register for the stack pointer, which ended up causing the assertion to trigger:
This triggered the invalid expectation in
amdgpu_segment_address_to_core_address. Because this is expressed as an assertion rather than a test triggering an error, this is not handled gracefully.
This patch fixes this by changing the assert into a "if (invalid_pred) errer (_(msg))" to gracefully handle invalid input. While at it, the patch also improved on the check to ensure that canonical addresses (where the address is sign-extended past the significant bits).
This also adds a test that exercises consuming invalid input as well as consuming sign extended addresses.
Change-Id: I3281f68b65eb817e949378f5548169c95cbf277c