You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect marshalling of Bool return types in new exception handling #113574
This is a four byte Win32 BOOL type. However, the native code uses 1-byte C++ bool type.
In the debug version of the runtime with MSVC compiler the contracts often trash the high bytes of the RAX/EAX register and thus an incorrect return value is marshalled.
changed the title [-]Incorrect matshalling of Bool return types in new exception handling[/-][+]Incorrect marshalling of Bool return types in new exception handling[/+]on Mar 15, 2025
In the debug version of the runtime with MSVC compiler the contracts often trash the high bytes of the RAX/EAX register and thus an incorrect return value is marshalled.
@filipnavara thank you for spotting this. I am surprised though that you have seen a problem occur, as I've never hit it in my testing that's always with debug / checked build.
It's probably dependent on a lot of factors including compiler versions. I initially spotted it when testing my win-x86 branch with funclets where the compiler was more prone to generate the patterns that only restored al register. That said, I was regularly comparing the runs with win-x64 and at least on one occasion I hit the problem there as well.
I don't remember which test hit the scenario but I was running the NativeAOT Exceptions test on CoreCLR which is normally excluded in the runs. That test explicitly runs throw new ...() inside the Main method and expects to hit the unhandled exception handler. It depends on the SfiNext return value to be correct to terminate the exception dispatch loop in the right place.
Activity
[-]Incorrect matshalling of Bool return types in new exception handling[/-][+]Incorrect marshalling of Bool return types in new exception handling[/+]janvorli commentedon Mar 17, 2025
@filipnavara thank you for spotting this. I am surprised though that you have seen a problem occur, as I've never hit it in my testing that's always with debug / checked build.
filipnavara commentedon Mar 17, 2025
It's probably dependent on a lot of factors including compiler versions. I initially spotted it when testing my win-x86 branch with funclets where the compiler was more prone to generate the patterns that only restored
alregister. That said, I was regularly comparing the runs with win-x64 and at least on one occasion I hit the problem there as well.I don't remember which test hit the scenario but I was running the NativeAOT Exceptions test on CoreCLR which is normally excluded in the runs. That test explicitly runs
throw new ...()inside theMainmethod and expects to hit the unhandled exception handler. It depends on theSfiNextreturn value to be correct to terminate the exception dispatch loop in the right place.