You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[wasm] AOT: System.Globalization.Calendars.Hybrid.WASM.Tests and System.Globalization.Hybrid.WASM.Tests getting terminated #94225
This is failing on rolling builds too, and is unrelated to the linked PR. Changes since the last passing rolling build - 8d59c90...920cd6e which includes #87672 .
I can't reproduce the same error. When we run wasm-library-aot-tests we add /p:BuildAOTTestsOnHelix=true /p:RunAOTCompilation=true. When reproducing this gives us an error AOT is not supported without IL trimming (PublishTrimmed=true required), so I added it. Am I missing something else? Log of such a run differs a lot:
/workspaces/runtime/src/mono/wasm/build/WasmApp.Native.targets(689,5): error : Precompiling failed for /workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/wasm_build/obj/wasm/for-build/aot-in/Microsoft.CSharp.dll with exit code 1. [/workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/publish/ProxyProjectForAOTOnHelix.proj]
/workspaces/runtime/src/mono/wasm/build/WasmApp.Native.targets(689,5): error : Failed to load method 0x600005d from '/workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/wasm_build/obj/wasm/for-build/aot-in/Microsoft.CSharp.dll' due to Could not resolve type with token 01000015 from typeref (expected class 'System.Collections.Generic.IEqualityComparer`1' in assembly 'System.Runtime, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') assembly:System.Runtime, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:System.Collections.Generic.IEqualityComparer`1 member:(null). [/workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/publish/ProxyProjectForAOTOnHelix.proj]
/workspaces/runtime/src/mono/wasm/build/WasmApp.Native.targets(689,5): error : Run with MONO_LOG_LEVEL=debug for more information. [/workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/publish/ProxyProjectForAOTOnHelix.proj]
....
/workspaces/runtime/src/mono/wasm/build/WasmApp.Native.targets(689,5): error : Could not load signature of Microsoft.DotNet.XHarness.TestRunners.Common.TestRunner:WriteResultsToFile due to: Could not resolve type with token 01000019 from typeref (expected class 'System.IO.TextWriter' in assembly 'System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e') assembly:System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e type:System.IO.TextWriter member:(null) [/workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/publish/ProxyProjectForAOTOnHelix.proj]
/workspaces/runtime/src/mono/wasm/build/WasmApp.Native.targets(689,5): error : Can't find custom attr constructor image: /workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/wasm_build/obj/wasm/for-build/aot-in/Microsoft.DotNet.XHarness.TestRunners.Common.dll mtoken: 0x0a00000a due to: Could not resolve type with token 01000011 from typeref (expected class 'System.Runtime.CompilerServices.AsyncStateMachineAttribute' in assembly 'System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e') assembly:System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e type:System.Runtime.CompilerServices.AsyncStateMachineAttribute member:(null) [/workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/publish/ProxyProjectForAOTOnHelix.proj]
/workspaces/runtime/src/mono/wasm/build/WasmApp.Native.targets(689,5): error : Failed to load custom attributes from method System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<string>> Microsoft.DotNet.XHarness.TestRunners.Common.ApplicationEntryPoint:GetIgnoredCategories () due to Could not resolve type with token 01000011 from typeref (expected class 'System.Runtime.CompilerServices.AsyncStateMachineAttribute' in assembly 'System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e') assembly:System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e type:System.Runtime.CompilerServices.AsyncStateMachineAttribute member:(null) [/workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/publish/ProxyProjectForAOTOnHelix.proj]
/workspaces/runtime/src/mono/wasm/build/WasmApp.Native.targets(689,5): error : FullAOT cannot continue if there are loader errors. [/workspaces/runtime/artifacts/bin/System.Globalization.Calendars.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/publish/ProxyProjectForAOTOnHelix.proj]
Can you share how exactly you are running the tests?
/p:BuildAOTTestsOnHelix=true - this isn't required. Use it if you are not able to reproduce without it. Essentially, it uses the same proxy project that we use on helix, for your local run too.
info: console.info: Initializing dotnet version 9.0.0-dev commit hash e4fbdb907bb187d7b5ba0668a84347c1058e3219
info: [MONO] Process terminated.
info: [MONO] Encountered infinite recursion while looking up resource 'Arg_NullReferenceException' in System.Private.CoreLib. Verify the installation of .NET is complete and does not need repairing, and that the state of the process has not become corrupted.
info: Process v8 exited with 1
Building with /p:UseSystemResourceKeys=true, I get:
info: console.info: Initializing dotnet version 9.0.0-dev commit hash e4fbdb907bb187d7b5ba0668a84347c1058e3219
info: MONO_WASM: at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[<RunAsync>d__4](<RunAsync>d__4& )
info: at Microsoft.DotNet.XHarness.TestRunners.Xunit.WasmApplicationEntryPoint.Run()
info: at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[<RunAsync>d__4](<RunAsync>d__4& )
info: at SimpleWasmTestRunner.Main(String[] args)
info: Error: TypeInitialization_Type, Microsoft.DotNet.XHarness.TestRunners.Common.ApplicationOptions
info: at Qn (/Users/ankj/dev/runtime/artifacts/bin/System.Globalization.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/_framework/dotnet.runtime.js:3:32681)
info: at Zn (/Users/ankj/dev/runtime/artifacts/bin/System.Globalization.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/_framework/dotnet.runtime.js:3:31798)
info: at p.javaScriptExports.call_entry_point (/Users/ankj/dev/runtime/artifacts/bin/System.Globalization.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/_framework/dotnet.runtime.js:3:210195)
info: at Object.ol [as runMain] (/Users/ankj/dev/runtime/artifacts/bin/System.Globalization.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/_framework/dotnet.runtime.js:3:141624)
info: at run (/Users/ankj/dev/runtime/artifacts/bin/System.Globalization.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/test-main.js:410:50)
info: at async /Users/ankj/dev/runtime/artifacts/bin/System.Globalization.Hybrid.WASM.Tests/Release/net9.0-browser/browser-wasm/AppBundle/test-main.js:426:1
The issue seems to be that CultureInfo..cctor indirectly calls CompareInfo..cctor, which then tries to access a static field from CultureInfo (s_InvariantCultureInfo), but that is null because it's cctor hasn't completed yet!
CultureInfo..cctor
-> CultureData..cctor
-> interp_runtime_invoke: >> method: System.Globalization.CalendarData:.cctor ()
-> interp_runtime_invoke: >> method: System.Globalization.GlobalizationMode/Settings:.cctor ()
-> Environment..cctor
-> Marshal..cctor
-> CompareInfo..cctor
- tries to use CultureInfo.s_invariant .. which hasn't been initialized yet!
This patch works around the issue causing the tests to pass:
diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs
index 31b17f3c4f5..c87c290a3fa 100644
--- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs+++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs@@ -102,7 +102,7 @@ public partial class CultureInfo : IFormatProvider, ICloneable
private static volatile CultureInfo? s_userDefaultUICulture;
// The Invariant culture;
- private static readonly CultureInfo s_InvariantCultureInfo = new CultureInfo(CultureData.Invariant, isReadOnly: true);+ private static CultureInfo? s_InvariantCultureInfo;
// These are defaults that we use if a thread has not opted into having an explicit culture
private static volatile CultureInfo? s_DefaultThreadCurrentUICulture;
@@ -462,7 +462,7 @@ public static CultureInfo InvariantCulture
{
get
{
- Debug.Assert(s_InvariantCultureInfo != null);+ s_InvariantCultureInfo ??= new CultureInfo(CultureData.Invariant, isReadOnly: true);
return s_InvariantCultureInfo;
}
}
So what happens is that a call is made to String.Equals(.., StringComparison.Ordinal), but the aot runtime executes class ctors too eagerly, so it executes the CompareInfo cctor because of this line:
case StringComparison.InvariantCulture:
case StringComparison.InvariantCultureIgnoreCase:
return CompareInfo.Invariant.Compare(this, value, GetCaseCompareOfComparisonCulture(comparisonType)) == 0;
CompareInfo is a beforefieldinit class, which means the runtime is supposed to be able to execute its cctor at any time before the moment of first access to its static members. So what mono is currently doing is correct. Its possible to change this, but it would mean that more type init checks would be done by the generated code, so it would be somewhat bigger/slower.
If the mono's behavior is correct then I believe the change in libs, similar to what Ankit proposed in #94225 (comment) will be needed to fix it. @tarekgh, are you fine with moving the initialization to the getter?
Activity
radical commentedon Oct 31, 2023
This might be a related failure too - #87672 (comment) .
radical commentedon Oct 31, 2023
cc @pavelsavara @maraf
ilonatommy commentedon Nov 1, 2023
I can't reproduce the same error. When we run
wasm-library-aot-testswe add/p:BuildAOTTestsOnHelix=true /p:RunAOTCompilation=true. When reproducing this gives us an errorAOT is not supported without IL trimming (PublishTrimmed=true required), so I added it. Am I missing something else? Log of such a run differs a lot:radical commentedon Nov 1, 2023
Can you share how exactly you are running the tests?
/p:BuildAOTTestsOnHelix=true- this isn't required. Use it if you are not able to reproduce without it. Essentially, it uses the same proxy project that we use on helix, for your local run too.radical commentedon Nov 1, 2023
Running this on macos with v8
11.6.6, I get:.. with a fresh build of e4fbdb9 .
radical commentedon Nov 1, 2023
Building with
/p:UseSystemResourceKeys=true, I get:16 remaining items
radical commentedon Nov 4, 2023
The issue seems to be that
CultureInfo..cctorindirectly callsCompareInfo..cctor, which then tries to access a static field fromCultureInfo(s_InvariantCultureInfo), but that isnullbecause it'scctorhasn't completed yet!This patch works around the issue causing the tests to pass:
radical commentedon Nov 4, 2023
Cc @vargaz
vargaz commentedon Nov 4, 2023
I can reproduce.
lewing commentedon Nov 7, 2023
@vargaz are you looking into this one?
vargaz commentedon Nov 7, 2023
What probably happens is AOT invokes cctors in a slighly different order.
vargaz commentedon Nov 8, 2023
So what happens is that a call is made to String.Equals(.., StringComparison.Ordinal), but the aot runtime executes class ctors too eagerly, so it executes the CompareInfo cctor because of this line:
will try to fix.
vargaz commentedon Nov 8, 2023
CompareInfo is a beforefieldinit class, which means the runtime is supposed to be able to execute its cctor at any time before the moment of first access to its static members. So what mono is currently doing is correct. Its possible to change this, but it would mean that more type init checks would be done by the generated code, so it would be somewhat bigger/slower.
ilonatommy commentedon Nov 20, 2023
If the mono's behavior is correct then I believe the change in libs, similar to what Ankit proposed in #94225 (comment) will be needed to fix it. @tarekgh, are you fine with moving the initialization to the getter?