-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzers
Description
Description
It seems that ILLink doesn't process UnsafeAccessorAttribute when used inside another method.
internal static Task RegisterWasiPollable(IPoll.Pollable pollable)
{
return CallRegisterWasiPollable((Thread)null!, 123);
[UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "RegisterWasiPollable")]
static extern Task CallRegisterWasiPollable(Thread t, int handle);
} Reproduction Steps
See
runtime/src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttpHandler.cs
Lines 464 to 475 in d606c60
| private static class WasiEventLoop | |
| { | |
| internal static Task RegisterWasiPollable(IPoll.Pollable pollable) | |
| { | |
| var handle = pollable.Handle; | |
| pollable.Handle = 0; | |
| return CallRegisterWasiPollable((Thread)null!, handle); | |
| [UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "RegisterWasiPollable")] | |
| static extern Task CallRegisterWasiPollable(Thread t, int handle); | |
| } | |
| } |
runtime/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.Unix.cs
Lines 15 to 23 in d606c60
| internal static System.Threading.Tasks.Task RegisterWasiPollable(int handle) | |
| { | |
| return WasiEventLoop.RegisterWasiPollable(handle); | |
| } | |
| internal static void DispatchWasiEventLoop() | |
| { | |
| WasiEventLoop.DispatchWasiEventLoop(); | |
| } |
Expected behavior
[UnsafeAccessor] on the nested external method will protect Thread.RegisterWasiPollable from trimming
Actual behavior
System.AggregateException: One or more errors occurred. (Could not find RegisterWasiPollableHandle)
---> System.MissingMethodException: Could not find RegisterWasiPollable
at System.Net.Http.WasiHttpHandler.WasiEventLoop.RegisterWasiPollable(Pollable )
at System.Net.Http.WasiHttpHandler.SendRequestAsync(OutgoingRequest )
at System.Net.Http.WasiHttpHandler.SendAsync(HttpRequestMessage , CancellationToken )
at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage , CancellationToken )
at Test.Work()
Regression?
No response
Known Workarounds
use ILLink.Descriptors.WASI.xml
Configuration
Net9 Prev 7
Other information
Discovered here
Metadata
Metadata
Assignees
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzers
Type
Projects
Status
No status