-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
LibraryImportGenerator tests failing on big-endian target (ref pointer type mismatch) #73775
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsOn s390x, the LibraryImportGenerator test cases have been disabled a while back: https://github.com/dotnet/runtime/pull/60833/files
which fails in this line:
The called function is declared using
and the automatically generated stub is built making the assumption that the called native routine uses an "uint8_t *" to implement the ref output (as indicated by the
However, the method actually being called is created from this definition:
via a DNNE-generated native stub:
Now, this called native routine will write its output to a "uint32_t *". This does not match the expectation of the caller. On a little-endian system, this may not be noticable in this case since the only effect is that a few unused bytes on the stack are clobbered. But on a big-endian system, the caller now actually reads the wrong byte of the result, which is why we see It appears to me that this is simply a bug in the test case. Is this correct, or is there something that should have a done some automatic type conversion / marshalling anywhere? CC @AaronRobinsonMSFT @jkoritzinsky
|
Hi @AaronRobinsonMSFT, thanks for the quick fix. With #73950 merged, the boolean tests now all pass. However, I'm still seeing failures in the character tests:
I think this problem is due to a similar mismatch here:
vs.
|
@uweigand Boo. That is sad. We are in a bad situation here. Is there anyway you can help track all the failing cases down in this case? For me, visually auditing the entire test suite is going to be tedious and error prone. If you can comment out the failing tests and open an issue with all the ones failing, it would be easy for me, with endianness in mind, to simply fix them in bulk. Appreciate these issues being brought up. |
@AaronRobinsonMSFT it looks like diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs
index ed4e18e22e1..64a4bca9fba 100644
--- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs
+++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/Characters.cs
@@ -21,9 +21,9 @@ public static uint ReturnUIntAsUInt(uint input)
}
[UnmanagedCallersOnly(EntryPoint = "char_return_as_refuint")]
- public static void ReturnUIntAsRefUInt(uint input, uint* res)
+ public static void ReturnUIntAsRefUInt(uint input, char* res)
{
- *res = input;
+ *res = (char)input;
}
[UnmanagedCallersOnly(EntryPoint = "char_reverse_buffer_ref")] |
Just to confirm that all |
On s390x, the LibraryImportGenerator test cases have been disabled a while back: https://github.com/dotnet/runtime/pull/60833/files
I've just tried running them again to check current status, and it looks like the original issue has been resolved, so the tests actually build and execute now. However, there are a number of test failures, all related to functions using a ref pointer to retrieve an output. One typical instance is:
which fails in this line:
The called function is declared using
LibraryImport
here:and the automatically generated stub is built making the assumption that the called native routine uses an "uint8_t *" to implement the ref output (as indicated by the
MarshalAs
attribute):However, the method actually being called is created from this definition:
via a DNNE-generated native stub:
Now, this called native routine will write its output to a "uint32_t *". This does not match the expectation of the caller. On a little-endian system, this may not be noticable in this case since the only effect is that a few unused bytes on the stack are clobbered. But on a big-endian system, the caller now actually reads the wrong byte of the result, which is why we see
False
as return value.It appears to me that this is simply a bug in the test case. Is this correct, or is there something that should have a done some automatic type conversion / marshalling anywhere?
CC @AaronRobinsonMSFT @jkoritzinsky
The text was updated successfully, but these errors were encountered: