-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[NativeAOT] Fix System.Runtime.InteropServices tests #75669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsAnd promote to NativeAOT smoke test.
|
|
|
||
| if (structuretype == null) | ||
| throw new ArgumentNullException(nameof(structuretype)); | ||
| throw new ArgumentNullException("structureType"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, the parameter name is structuretype in the ref assembly, but we cannot even consistently make up a wrong name that would stick and call it structureType or structure (and write tests for it).
...clr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs
Outdated
Show resolved
Hide resolved
…e/InteropServices/Marshal.NativeAot.cs Co-authored-by: Jan Kotas <[email protected]>
| public static bool Is64BitProcess => IntPtr.Size == 8; | ||
| public static bool IsNotWindows => !IsWindows; | ||
|
|
||
| public static bool IsSehInteropSupported => !IsMonoRuntime && !IsNativeAot; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also include && IsWindows? I'm saying this because "Seh" is a Windows tech that should be limited to that platform. We should rename if this is describing a more general restriction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SEH specific APIs this is guarding work on CoreCLR, probably because of the built-in Win32 API emulator. The tests don't appear blocked for CoreCLR outside Windows. Is there a better name for "Marshal.GetExceptionCode and Marshal.GetExceptionPointers works"? (Or a broader question - do we need them to work outside Windows or should they just be PNSE?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah these APIs work on CoreCLR on non-Windows because the PAL layer emulates SEH and VEH-style structures for the exception handling infrastructure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the PAL layer emulates SEH and VEH-style structures for the exception handling infrastructure.
That is an implementation detail though. SEH is partially emulated in the sense we mimic it for managed exception handling but SEH as a concept isn't supported on non-Windows. Encoding it this way and saying it is emulated isn't really fair because we don't do propagation of exceptions in the way we do on Windows, which is what SEH really provides to us - a consistent exception contract we can rely upon for interop.
Or a broader question - do we need them to work outside Windows or should they just be PNSE?
@MichalStrehovsky I agree with this statement to be honest. The doc does state it is only supported for SEH, which to me means it isn't supported on non-Windows and can therefore throw a PNSE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also a nit, so we can make progress on this otherwise. Please file an issue and @jkoritzinsky or I can work with JanV on the API changes and/or debate a better name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remarks section says "GetExceptionPointers is exposed for compiler support of structured exception handling (SEH) only.". I think that it is still an accurate general statement. People can use the API for other purposes if they know what they are doing, but we do not need to endorse or encourage in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions for the naming of PlatformDetection.IsSehInteropSupported? PlatformDetection.IsHalfassedSehInteropSupported? I think that's the last piece of unaddressed feedback here. I'm not good with names and I'm obviously fine with naming it IsSehInteropSupported. I don't know what is the thing we actually support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call it IsMarshalGetExceptionPointersSupported. It is exactly what this protects currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also guards GetExceptionCode. Is the suggestion to have a separate PlatformDetection for each API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. I really dislike use of SEH because I immediately go to Windows only. Jan's suggestion works for me.
|
@AaronRobinsonMSFT @jkoritzinsky is there something you would like me to adjust? |
And promote to NativeAOT smoke test.
Fixes #73145.