Skip to content

proc: fix SP calculation for sigpanic frames on arm64#4319

Merged
derekparker merged 2 commits into
go-delve:masterfrom
alexsaezm:issue-3591
Apr 30, 2026
Merged

proc: fix SP calculation for sigpanic frames on arm64#4319
derekparker merged 2 commits into
go-delve:masterfrom
alexsaezm:issue-3591

Conversation

@alexsaezm

Copy link
Copy Markdown
Contributor

Stack traces from linux/arm64 core dumps showed SP values that differed from the runtime's panic output.

This patch adds a reproducer based on the original snippet from the issue and a test that tries to verify if the SP is the same.

Fixes #3591

@alexsaezm

Copy link
Copy Markdown
Contributor Author

For the record, I'm not really sure if this is the best approach because it feels wrong to depend on exec.Command but as far as I understood from the original report, this only happens on Linux, and they are common tools.

Also, not sure if using TempDir is a good idea; maybe this will break on the CI...

Comment thread pkg/proc/stack.go
Comment thread pkg/proc/core/core_test.go Outdated
}
mustSupportCore(t)

tempDir := t.TempDir()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this is just withCoreFile right? The only difference is the part where it also reads the stderr? If so we should probably just modify withCoreFile to call CombinedOutput() and return it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I updated withCoreFile to call CombinedOutput, and then removed all the noise in the new test. Way cleaner for sure.

Without this fix, stack traces from linux/arm64 core dumps showed SP
values that differed from the runtime's panic output.

Fixes go-delve#3591

@aarzilli aarzilli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekparker derekparker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekparker derekparker merged commit 59d9aee into go-delve:master Apr 30, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

arm64 core, the regs command get the wrong SP after nil pointer dereference

3 participants