Skip to content
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

Crossgen outerloop regression: Missing unhandled exception header in unhandledTester #109203

Open
kg opened this issue Oct 24, 2024 · 9 comments
Open
Labels
area-crossgen2-coreclr untriaged New issue has not been triaged by the area owner

Comments

@kg
Copy link
Member

kg commented Oct 24, 2024

/home/kate/Projects/dotnet-runtime-wasm/artifacts/tests/coreclr/linux.x64.Release/Tests/Core_Root/corerun -p System.Reflection.Metadata.MetadataUpdater.IsSupported=false -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true unhandledTester.dll ''
"Unhandled exception. System.Exception: Test"
"   at TestUnhandledException.Program.Main(String[] args)"
""
Test process unhandled.dll with argument main exited
Test process exited with expected error code and produced expected output
"Unhandled exception. System.EntryPointNotFoundException: Unable to find an entry point named 'HelloCpp' in shared library '__internal'."
"   at TestUnhandledException.Program.Test()"
"   at TestUnhandledException.Program.ThrowException()"
""
Test process unhandled.dll with argument foreign exited
System.Exception: Missing Unhandled exception header
   at TestUnhandledExceptionTester.Program.RunExternalProcess(String unhandledType, String assembly) in /home/kate/Projects/dotnet-runtime-wasm/src/tests/baseservices/exceptions/unhandled/unhandledTester.cs:line 103
   at TestUnhandledExceptionTester.Program.TestEntryPoint() in /home/kate/Projects/dotnet-runtime-wasm/src/tests/baseservices/exceptions/unhandled/unhandledTester.cs:line 123
   at __GeneratedMainWrapper.Main() in /home/kate/Projects/dotnet-runtime-wasm/artifacts/tests/coreclr/obj/linux.x64.Release/Managed/baseservices/exceptions/unhandled/unhandledTester/XUnitWrapperGenerator/XUnitWrapperGenerator.XUnitWrapperGenerator/SimpleRunner.g.cs:line 7
in ReleaseLock
Expected: 100
Actual: 101
END EXECUTION - FAILED
Test Harness Exitcode is : 1
To run the test:
Set up CORE_ROOT and run.
> /home/kate/Projects/dotnet-runtime-wasm/artifacts/tests/coreclr/linux.x64.Release/baseservices/exceptions/baseservices-exceptions/../unhandled/unhandledTester/unhandledTester.sh
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Oct 24, 2024
@am11
Copy link
Member

am11 commented Oct 24, 2024

cc @janvorli, this one looks like the foreign thread is not able to set the resolver on executing assembly

(note that PR #109204 will disable this test)

@janvorli
Copy link
Member

@kg is this is wasm specific or am I just mislead by the folder name in the log above?

@janvorli
Copy link
Member

The problem is that the tester expects to get

Unhandled exception. System.DllNotFoundException:

But it gets

Unhandled exception. System.EntryPointNotFoundException

If the issue is WASM only and it is expected that WASM would generate a different exception, then the src/tests/baseservices/exceptions/unhandled/unhandledTester.cs should be modified to check for a different exception on WASM.

I was not able to repro this on Linux x64.

@jkotas
Copy link
Member

jkotas commented Oct 25, 2024

This is regular CoreCLR. The tests only fails when compiled as R2R.

I think the problem is that the test is not properly compensating for variance in behavior that is allowed due to optimizations. From https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.suppressgctransitionattribute :

Applying this attribute can cause the P/Invoke export to be bound earlier as a side-effect of the calling method being JIT compiled. EntryPointNotFoundException or other exceptions might be thrown earlier than when the attribute is not applied.

It can fixed by moving code around and applying NoInline attributes to ensure that the behavior is not affected by optimizations.

@janvorli
Copy link
Member

I was actually trying to repro it on Linux x64 release build with R2R enabled and it didn't repro. So I wonder which DOTNET_xxx variables need to be set to get it repro.

@kg
Copy link
Member Author

kg commented Oct 25, 2024

This is my repro script, though it doesn't match CI for some reason:

rm -rf ./artifacts
rm -rf ./artifacts/tests
rm -rf ./.dotnet
./build.sh Clr+Tools+Libs -c Release -rc $1 --os linux

./src/tests/build.sh $1 -priority1 -crossgen2 -p:LibrariesConfiguration=Release
PATH=/home/kate/Projects/dotnet-runtime-wasm/.dotnet/:$PATH RunCrossGen2=1 CompositeBuildMode=1 src/tests/run.sh $1

With 'Checked' passed as $1 since a lot of the CI lanes are Checked. For me this repros around half of the CI failures.

@janvorli
Copy link
Member

janvorli commented Oct 25, 2024

Thank you @kg, the CompositeBuildMode=1 is what triggers the issue to happen.

@kg
Copy link
Member Author

kg commented Oct 25, 2024

I should have been more precise, sorry for wasting your time. I think the CI lanes are also composite.

@janvorli
Copy link
Member

No worries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-crossgen2-coreclr untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

4 participants