Skip to content
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

fix(internal/utils): fix clobbering BP #288

Merged
merged 3 commits into from
Feb 18, 2025

Conversation

zeroshade
Copy link
Member

Rationale for this change

Fixes #279

What changes are included in this PR?

In all instances where the generated assembly is clobbering the BP register, we insert a frame size so that the Go assembler will insert a save/restore of the BP, preventing the spurious crash discovered in #279

Are these changes tested?

There isn't really a consistent way to easily reproduce in a unit test, but I'm open to suggestions if anyone has one

Are there any user-facing changes?

No

@zeroshade zeroshade requested review from kou and lidavidm February 17, 2025 21:54
@@ -488,7 +488,7 @@ LBB3_5:
DATA LCDATA3<>+0x000(SB)/8, $0x7fffffff80000000
GLOBL LCDATA3<>(SB), 8, $8

TEXT ·_int32_max_min_avx2(SB), $0-32
TEXT ·_int32_max_min_avx2(SB), NOSPLIT, $8-32
Copy link
Member

Choose a reason for hiding this comment

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

Is the NOSPLIT only needed here and not in the other locations?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, I can probably add it to the other locations for the benefits

@@ -133,7 +133,7 @@ LBB0_5:
JNE LBB0_9
JMP LBB0_10

TEXT ·_uint8_max_min_avx2(SB), $0-32
TEXT ·_uint8_max_min_avx2(SB), NOSPLIT, $0-32
Copy link
Member

Choose a reason for hiding this comment

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

I'm not familiar with assembly but is $0 OK here? Should we use $8 like others?

Copy link
Member Author

Choose a reason for hiding this comment

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

the $0 is the Frame Size. We only needed to update to $8 in the cases that included the LEAQ <something>, BP instruction since those were clobbering the BP. By updating the frame size the Go assembler will automatically insert instructions to save/restore the BP. In the cases where we weren't clobbering it, we don't need to update or change the frame size.

@zeroshade zeroshade merged commit e888669 into apache:main Feb 18, 2025
23 checks passed
@zeroshade zeroshade deleted the fix-clobber-bp branch February 18, 2025 17:42
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.

SEGSEGV during goroutine switch while utils.int32MaxMinAVX2 is running
3 participants