Skip to content

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented Jul 26, 2024

Fixes #105518

The root cause of the issue is the IR like this:

[000852] UAC-G------                         *  STORE_LCL_FLD struct<System.Decimal, 16> V41 tmp36        [+8]
[000849] S-C-G------                         \--*  CALLV vt-ind struct Microsoft.Data.Sqlite.SqliteValueReader:GetDecimal(int):System.Decimal:this
[000847] ----------- this                       +--*  LCL_VAR   ref    V00 this         
[000848] ----------- arg1                       \--*  LCL_VAR   int    V02 arg1     

since that call demands a ret-buffer (to return System.Decimal) on Windows, we have to spill it right in the importer. @jakobbotsch pointed me to impStoreStruct helper that takes care about ABI for such stores.

This led to an assert in LowerStructCall in Checked and to an invalid program exception in Release in EF. I've validated that this fix fixes the EF repro.

It's a bit unfortunate that we have to care about codegen-level things like ABI handling that early, but 🤷

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 26, 2024
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@EgorBo EgorBo marked this pull request as ready for review July 26, 2024 08:34
@EgorBo
Copy link
Member Author

EgorBo commented Jul 26, 2024

The root cause of the issue is the IR like this:

[000852] UAC-G------                         *  STORE_LCL_FLD struct<System.Decimal, 16> V41 tmp36        [+8]
[000849] S-C-G------                         \--*  CALLV vt-ind struct Microsoft.Data.Sqlite.SqliteValueReader:GetDecimal(int):System.Decimal:this
[000847] ----------- this                       +--*  LCL_VAR   ref    V00 this         
[000848] ----------- arg1                       \--*  LCL_VAR   int    V02 arg1     

since that call demands a ret-buffer (to return System.Decimal) on Windows, we have to spill it right in the importer. @jakobbotsch pointed me to impStoreStruct helper that takes care about ABI for such stores.

This led to an assert in LowerStructCall in Checked and to an invalid program exception in Release in EF. I've validated that this fix fixes the EF repro.

PTAL @jakobbotsch @AndyAyersMS

@EgorBo EgorBo merged commit ebbebac into dotnet:main Jul 26, 2024
@EgorBo EgorBo deleted the spill-sideeffects-store-nullable branch July 26, 2024 15:28
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 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.

The JIT compiler encountered invalid IL code or an internal limitation.

2 participants