Minimal standalone NativeAOT repro for the ILC crash seen in: https://github.com/npgsql/npgsql/actions/runs/24466578450/job/71495217567?pr=6488
Requires the .NET 11 preview SDK (
11.0.100-preview.3.26207.106or later). Seeglobal.json.
cd ReproAsyncAotJson
dotnet publish -c ReleaseThe runtime-async feature is enabled by default via the RuntimeAsync MSBuild property in the .csproj.
As of Preview 3, <EnablePreviewFeatures>true</EnablePreviewFeatures> is no longer required — only <Features>runtime-async=on</Features> is needed (release notes):
<!-- Set to false to verify the issue only occurs with runtime-async enabled -->
<RuntimeAsync Condition="'$(RuntimeAsync)' == ''">true</RuntimeAsync>To confirm the crash is only triggered by runtime-async, pass RuntimeAsync=false:
dotnet publish -c Release -p:RuntimeAsync=false # succeeds
dotnet publish -c Release -p:RuntimeAsync=true # fails (default)The failing pattern is the generic async overload called from a generic method:
await JsonSerializer.DeserializeAsync(stream, typeInfoOfT, cancellationToken)Replace the generic DeserializeAsync<T> calls with the non-generic overload using JsonTypeInfo:
(T?)await JsonSerializer.DeserializeAsync(stream, (JsonTypeInfo)typeInfoOfT, cancellationToken)