- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.2k
 
Closed
Labels
area-ExceptionHandling-coreclrin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
The managed prototypes for RhpSfiInit, RhpSfiNext and few other methods specify UnmanagedType.Bool for the return values:
runtime/src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/InternalCalls.cs
Lines 15 to 21 in 4ca1691
| [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "SfiInit")] | |
| [return: MarshalAs(UnmanagedType.Bool)] | |
| internal static unsafe partial bool RhpSfiInit(ref StackFrameIterator pThis, void* pStackwalkCtx, [MarshalAs(UnmanagedType.Bool)] bool instructionFault, bool* fIsExceptionIntercepted); | |
| [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "SfiNext")] | |
| [return: MarshalAs(UnmanagedType.Bool)] | |
| internal static unsafe partial bool RhpSfiNext(ref StackFrameIterator pThis, uint* uExCollideClauseIdx, bool* fUnwoundReversePInvoke, bool* fIsExceptionIntercepted); | 
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.
/cc @janvorli
Metadata
Metadata
Assignees
Labels
area-ExceptionHandling-coreclrin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged