Skip to content

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

Merged
zeroshade merged 3 commits intoapache:mainfrom
zeroshade:fix-clobber-bp
Feb 18, 2025
Merged

fix(internal/utils): fix clobbering BP#288
zeroshade merged 3 commits intoapache:mainfrom
zeroshade:fix-clobber-bp

Conversation

@zeroshade
Copy link
Copy Markdown
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
GLOBL LCDATA3<>(SB), 8, $8

TEXT ·_int32_max_min_avx2(SB), $0-32
TEXT ·_int32_max_min_avx2(SB), NOSPLIT, $8-32
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.

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

Copy link
Copy Markdown
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

JMP LBB0_10

TEXT ·_uint8_max_min_avx2(SB), $0-32
TEXT ·_uint8_max_min_avx2(SB), NOSPLIT, $0-32
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.

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

Copy link
Copy Markdown
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