-
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
.NET 8 WebAssembly AOT not generating trampoline functions #97906
Comments
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescriptionWhen building trampoline functions to call into native code, delegates marked the the Since .NET 8, natively calling into these methods once again causes Reproduction StepsA minimal WebGL sample that encounters the bug is located here: AshleighAdams/dotnet-webgl-sample#6 Note, that you must AOT build the sample: $ dotnet publish --configuration Release -p:OutputPath="$(pwd)/build" && (cd build/AppBundle/ && dotnet serve -o) Internally, the sample is calling into emscripten's GL via Silk.NET, and in the project the following delegate can be found to get AOT to trampoline the function:
Expected behaviorExpect .NET to trampoline the call into native code correctly Actual behaviorCrashes with an exception:
Regression?Yes, it worked in .NET 6 and .NET 7 Known WorkaroundsUnknown for now ConfigurationWebGL, happens when built on Linux and Windows Other informationIn .NET 7, a snippet that referenced the function pointer existed to stop it from being trimmed, I tried this again but additionally on Marshal.GetDelegateForFunctionPointer(new nint(1), typeof(glClearColor_t)); and I also tried adding the dynamic dependency to my trampoline class: [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(TrampolineFuncs))] Neither of these had any success The previous .NET 7 regression issue is here: #76930
|
cc @vargaz @kg @steveisok |
Are there any warnings or related messages in the build log? |
@kg Not that I can see, full build log is here: https://github.com/AshleighAdams/dotnet-webgl-sample/actions/runs/7762714845/job/21173670804 |
@kg what is the status of this one? |
I didn't have an opportunity to get to the bottom of it |
This is fixed in .NET 9 preview 6 Is there anything we can do to help prevent this from regressing a third time? I know this isn't an "officially" supported part of wasm yet, but nonetheless I think it is still very important |
We could add a simple regression test for it. I added a small suite of P/Invoke tests to our test suite while doing my p/invoke work during .NET 9. It's not obvious to me why the glClearColor call from the original report wouldn't have gotten a trampoline, though - someone who knows our AOT infrastructure better might be able to guess. |
Description
When building trampoline functions to call into native code, delegates marked the the
UnmanagedFunctionPointer
attribute in .NET 6, and .NET 7 (tho not upon initial release) are taken into account.Since .NET 8, natively calling into these methods once again causes
mono_wasm_get_interp_to_native_trampoline()
to fail, and the application to crash.Reproduction Steps
A minimal WebGL sample that encounters the bug is located here: AshleighAdams/dotnet-webgl-sample#6
Note, that you must AOT build the sample:
Internally, the sample is calling into emscripten's GL via Silk.NET, and in the project the following delegate can be found to get AOT to trampoline the function:
Expected behavior
Expect .NET to trampoline the call into native code correctly
Actual behavior
Crashes with an exception:
Regression?
Yes, it worked in .NET 6 and .NET 7
Known Workarounds
Unknown for now
Configuration
WebGL, happens when built on Linux and Windows
Issue is in both Chrome and Firefox, latest versions
Other information
In .NET 7, a snippet that referenced the function pointer existed to stop it from being trimmed, I tried this again but additionally on
glClearColor_t()
which is getting trimmed:and I also tried adding the dynamic dependency to my trampoline class:
Neither of these had any success
The previous .NET 7 regression issue is here: #76930
The text was updated successfully, but these errors were encountered: