Skip to content

Conversation

@BruceForstall
Copy link
Contributor

When passing a struct by value on x86, we copy its value to the stack. Sometimes this is done one field at a time, if the struct has been promoted. If there is padding between the fields (to create appropriate field alignment), then that padding needs to be zeroed.

The bug is a case where there is padding between an earlier double field and a later, larger, SIMD field. We push 4-byte zeros but the code thinks it is pushing 8-byte zeros. The fix is simply to correctly calculate the number of zeros to push.

Fixes #106140

When passing a struct by value on x86, we copy its value to the stack.
Sometimes this is done one field at a time, if the struct has been
promoted. If there is padding between the fields (to create appropriate
field alignment), then that padding needs to be zeroed.

The bug is a case where there is padding between an earlier `double`
field and a later, larger, SIMD field. We push 4-byte zeros but the code thinks
it is pushing 8-byte zeros. The fix is simply to correctly calculate the number
of zeros to push.

Fixes dotnet#106140
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 15, 2024
@BruceForstall
Copy link
Contributor Author

Based on #106516.

I saw no x86 asm diffs locally.

@BruceForstall
Copy link
Contributor Author

@AndyAyersMS @dotnet/jit-contrib PTAL

Copy link
Contributor

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

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

LGTM

@kunalspathak
Copy link
Contributor

should this be backported given the simple repro? what happens in release mode?

@BruceForstall BruceForstall merged commit e1a14a8 into dotnet:main Oct 15, 2024
112 of 114 checks passed
@BruceForstall BruceForstall deleted the Fix106140 branch October 15, 2024 05:22
@BruceForstall
Copy link
Contributor Author

should this be backported given the simple repro? what happens in release mode?

IMO, it's too late. The assert is a noway_assert, so it fails in release mode (the JIT crashes). Also, apparently this failure existed in .NET 8 according to Will.

@BruceForstall
Copy link
Contributor Author

No diffs

@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: Assertion failed '(ssize_t)emitCurStackLvl >= argSize'

2 participants