Open AshleighAdams opened 9 months ago
Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.
Author: | AshleighAdams |
---|---|
Assignees: | - |
Labels: | `arch-wasm`, `untriaged`, `area-Interop-mono` |
Milestone: | - |
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?
@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: https://github.com/AshleighAdams/dotnet-webgl-sample/pull/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: https://github.com/dotnet/runtime/issues/76930