Skip to content
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

[wasm][AOT] Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument Exception #49770

Closed
mdh1418 opened this issue Mar 17, 2021 · 4 comments · Fixed by #49789
Closed

[wasm][AOT] Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument Exception #49770

mdh1418 opened this issue Mar 17, 2021 · 4 comments · Fixed by #49789
Labels
arch-wasm WebAssembly architecture area-Codegen-AOT-mono untriaged New issue has not been triaged by the area owner

Comments

@mdh1418
Copy link
Member

mdh1418 commented Mar 17, 2021

There is an ongoing effort to better understand the failures encountered when running wasm library tests with AOT compilation on CI. In the past week, this error #49717 began surfacing. In an attempt to reproduce #49717 and figuring out the scope, now this error is being hit.

This error has been seen in System.Buffers.Tests.csproj, Common.Tests.csproj, and System.ComponentModel.TypeConverter.Tests.csproj with RunAOTCompilation=true (regardless of the value of EnableAggressiveTrimming). When RunAOTCompilation=false (regardless of the value of EnableAggressiveTrimming, the tests run to completion with no failures.

Error

XHarness command issued: wasm test --app=. --engine=V8 --engine-arg=--stack-trace-limit=1000 --js-file=runtime.js --output-directory=/Users/mdhwang/steveisok/artifacts/bin/System.Buffers.Tests/net6.0-Release/browser-wasm/AppBundle/xharness-output -- --run WasmTestRunner.dll System.Buffers.Tests.dll -notrait category=OuterLoop -notrait category=failing
  info: 13:34:34.5702650 Running v8 --expose_wasm --stack-trace-limit=1000 runtime.js -- --run WasmTestRunner.dll System.Buffers.Tests.dll -notrait category=OuterLoop -notrait category=failing


  fail: 13:34:35.6904480 console.error: System.AggregateException: One or more errors occurred. (Specified cast is not valid.)

  fail: 13:34:35.6906540  ---> System.InvalidCastException: Specified cast is not valid.

  fail: 13:34:35.6906640    at Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument[Int32](String argumentName)

  fail: 13:34:35.6906680 --- End of stack trace from previous location ---

  fail: 13:34:35.6906700    at Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument[Int32](String argumentName)

  fail: 13:34:35.6906830 --- End of stack trace from previous location ---

  fail: 13:34:35.6906850    at Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument[Int32](String argumentName)

  fail: 13:34:35.6906870    --- End of inner exception stack trace ---

  info: console.info: Arguments: --run,WasmTestRunner.dll,System.Buffers.Tests.dll,-notrait,category=OuterLoop,-notrait,category=failing
  info: console.debug: MONO_WASM: Initializing mono runtime
  info: console.debug: MONO_WASM: ICU data archive(s) loaded, disabling invariant mode
  info: console.debug: mono_wasm_runtime_ready fe00e07a-5519-4dfe-b35a-f867dbaf2e28
  info: console.info: Initializing.....
  info: Discovering: System.Buffers.Tests.dll (method display = ClassAndMethod, method display options = None)
  info: 13:34:35.7234490 Process v8 exited with 1

  fail: Application has finished with exit code 1 but 0 was expected
  XHarness exit code: 71 (GENERAL_FAILURE)
  XHarness artifacts: /Users/mdhwang/steveisok/artifacts/bin/System.Buffers.Tests/net6.0-Release/browser-wasm/AppBundle/xharness-output
/Users/mdhwang/steveisok/eng/testing/tests.targets(117,5): error : One or more tests failed while running tests from 'System.Buffers.Tests'. [/Users/mdhwang/steveisok/src/libraries/System.Buffers/tests/System.Buffers.Tests.csproj]

Repro

Running library tests on Browser wasm based on 4e3deb5
Make the following changes to prevent linking out xunit related assemblies and skip an exception filter error with AOT compilation.

mdhwang:~/runtime_wasm_clean$ git diff
diff --git a/eng/testing/ILLink.Descriptor.xunit.xml b/eng/testing/ILLink.Descriptor.xunit.xml
index 4ddd4e09d88..c137141b171 100644
--- a/eng/testing/ILLink.Descriptor.xunit.xml
+++ b/eng/testing/ILLink.Descriptor.xunit.xml
@@ -9,7 +9,15 @@
     </type>
     <type fullname="Xunit.Sdk.FactDiscoverer" />
   </assembly>
-  <assembly fullname="xunit.core">
-    <namespace fullname="Xunit" />
+  <assembly fullname="xunit.core"/>
+  <assembly fullname="Microsoft.DotNet.XUnitExtensions"/>
+  <assembly fullname="mscorlib" />
+  <assembly fullname="TestUtilities">
+    <namespace fullname="System" />
   </assembly>
+  <assembly fullname="xunit.abstractions" />
+  <assembly fullname="xunit.assert" />
+  <assembly fullname="xunit.runner.utility.netcoreapp10" />
+  <assembly fullname="Microsoft.DotNet.XHarness.TestRunners.Xunit" />
+  <assembly fullname="Microsoft.DotNet.XHarness.TestRunners.Common" />
 </linker>
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/LegacyFileStreamStrategy.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/LegacyFileStreamStrategy.Unix.cs
index 26818014bbb..45907d37104 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/LegacyFileStreamStrategy.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/LegacyFileStreamStrategy.Unix.cs
@@ -172,7 +172,7 @@ protected override void Dispose(bool disposing)
                     {
                         FlushWriteBuffer();
                     }
-                    catch (Exception e) when (!disposing && FileStream.IsIoRelatedException(e))
+                    catch
                     {
                         // On finalization, ignore failures from trying to flush the write buffer,
                         // e.g. if this stream is wrapping a pipe and the pipe is now broken.

./build.sh -os Browser -arch wasm -c Release
./dotnet.sh build /t:Test /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=Release /p:EnableAggressiveTrimming=true /p:RunAOTCompilation=true src/libraries/System.Buffers/tests/System.Buffers.Tests.csproj

@mdh1418 mdh1418 added arch-wasm WebAssembly architecture area-Codegen-AOT-mono labels Mar 17, 2021
@ghost
Copy link

ghost commented Mar 17, 2021

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

There is an ongoing effort to better understand the failures encountered when running wasm library tests with AOT compilation on CI. In the past week, this error #49717 began surfacing. In an attempt to reproduce #49717 and figuring out the scope, now this error is being hit.

This error has been seen in System.Buffers.Tests.csproj, Common.Tests.csproj, and System.ComponentModel.TypeConverter.Tests.csproj with RunAOTCompilation=true (regardless of the value of EnableAggressiveTrimming). When RunAOTCompilation=false (regardless of the value of EnableAggressiveTrimming, the tests run to completion with no failures.

Error

XHarness command issued: wasm test --app=. --engine=V8 --engine-arg=--stack-trace-limit=1000 --js-file=runtime.js --output-directory=/Users/mdhwang/steveisok/artifacts/bin/System.Buffers.Tests/net6.0-Release/browser-wasm/AppBundle/xharness-output -- --run WasmTestRunner.dll System.Buffers.Tests.dll -notrait category=OuterLoop -notrait category=failing
  info: 13:34:34.5702650 Running v8 --expose_wasm --stack-trace-limit=1000 runtime.js -- --run WasmTestRunner.dll System.Buffers.Tests.dll -notrait category=OuterLoop -notrait category=failing


  fail: 13:34:35.6904480 console.error: System.AggregateException: One or more errors occurred. (Specified cast is not valid.)

  fail: 13:34:35.6906540  ---> System.InvalidCastException: Specified cast is not valid.

  fail: 13:34:35.6906640    at Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument[Int32](String argumentName)

  fail: 13:34:35.6906680 --- End of stack trace from previous location ---

  fail: 13:34:35.6906700    at Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument[Int32](String argumentName)

  fail: 13:34:35.6906830 --- End of stack trace from previous location ---

  fail: 13:34:35.6906850    at Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument[Int32](String argumentName)

  fail: 13:34:35.6906870    --- End of inner exception stack trace ---

  info: console.info: Arguments: --run,WasmTestRunner.dll,System.Buffers.Tests.dll,-notrait,category=OuterLoop,-notrait,category=failing
  info: console.debug: MONO_WASM: Initializing mono runtime
  info: console.debug: MONO_WASM: ICU data archive(s) loaded, disabling invariant mode
  info: console.debug: mono_wasm_runtime_ready fe00e07a-5519-4dfe-b35a-f867dbaf2e28
  info: console.info: Initializing.....
  info: Discovering: System.Buffers.Tests.dll (method display = ClassAndMethod, method display options = None)
  info: 13:34:35.7234490 Process v8 exited with 1

  fail: Application has finished with exit code 1 but 0 was expected
  XHarness exit code: 71 (GENERAL_FAILURE)
  XHarness artifacts: /Users/mdhwang/steveisok/artifacts/bin/System.Buffers.Tests/net6.0-Release/browser-wasm/AppBundle/xharness-output
/Users/mdhwang/steveisok/eng/testing/tests.targets(117,5): error : One or more tests failed while running tests from 'System.Buffers.Tests'. [/Users/mdhwang/steveisok/src/libraries/System.Buffers/tests/System.Buffers.Tests.csproj]

Repro

Running library tests on Browser wasm based on 4e3deb5
Make the following changes to prevent linking out xunit related assemblies and skip an exception filter error with AOT compilation.

mdhwang:~/runtime_wasm_clean$ git diff
diff --git a/eng/testing/ILLink.Descriptor.xunit.xml b/eng/testing/ILLink.Descriptor.xunit.xml
index 4ddd4e09d88..c137141b171 100644
--- a/eng/testing/ILLink.Descriptor.xunit.xml
+++ b/eng/testing/ILLink.Descriptor.xunit.xml
@@ -9,7 +9,15 @@
     </type>
     <type fullname="Xunit.Sdk.FactDiscoverer" />
   </assembly>
-  <assembly fullname="xunit.core">
-    <namespace fullname="Xunit" />
+  <assembly fullname="xunit.core"/>
+  <assembly fullname="Microsoft.DotNet.XUnitExtensions"/>
+  <assembly fullname="mscorlib" />
+  <assembly fullname="TestUtilities">
+    <namespace fullname="System" />
   </assembly>
+  <assembly fullname="xunit.abstractions" />
+  <assembly fullname="xunit.assert" />
+  <assembly fullname="xunit.runner.utility.netcoreapp10" />
+  <assembly fullname="Microsoft.DotNet.XHarness.TestRunners.Xunit" />
+  <assembly fullname="Microsoft.DotNet.XHarness.TestRunners.Common" />
 </linker>
diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/LegacyFileStreamStrategy.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/LegacyFileStreamStrategy.Unix.cs
index 26818014bbb..45907d37104 100644
--- a/src/libraries/System.Private.CoreLib/src/System/IO/LegacyFileStreamStrategy.Unix.cs
+++ b/src/libraries/System.Private.CoreLib/src/System/IO/LegacyFileStreamStrategy.Unix.cs
@@ -172,7 +172,7 @@ protected override void Dispose(bool disposing)
                     {
                         FlushWriteBuffer();
                     }
-                    catch (Exception e) when (!disposing && FileStream.IsIoRelatedException(e))
+                    catch
                     {
                         // On finalization, ignore failures from trying to flush the write buffer,
                         // e.g. if this stream is wrapping a pipe and the pipe is now broken.

./build.sh -os Browser -arch wasm -c Release
./dotnet.sh build /t:Test /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=Release /p:EnableAggressiveTrimming=true /p:RunAOTCompilation=true src/libraries/System.Buffers/tests/System.Buffers.Tests.csproj

Author: mdh1418
Assignees: -
Labels:

arch-wasm, area-Codegen-AOT-mono

Milestone: -

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 17, 2021
@tqiu8
Copy link
Contributor

tqiu8 commented Mar 17, 2021

We found that this error started occurring after #49072 was merged in to master.

@lewing
Copy link
Member

lewing commented Mar 17, 2021

cc @SamMonoRT @BrzVlad

@BrzVlad
Copy link
Member

BrzVlad commented Mar 17, 2021

Do methods with filters run with interp even in aot case ? Or just the filter clause is interpreted ? Or what's the catch here ?

radical added a commit to radical/runtime that referenced this issue Mar 17, 2021
…et#49072)"

This reverts commit 686f752.

Reverting this for now, as a workaround to get the AOT library tests
working again.

Running library tests with AOT+EnableAggressiveTrimming broke with:

```
  info: Arguments: --run,WasmTestRunner.dll,System.Buffers.Tests.dll,-notrait,category=OuterLoop,-notrait,category=failing
  info: Initializing.....
  fail: System.AggregateException: AggregateException_ctor_DefaultMessage (Arg_NullReferenceException)
         ---> System.NullReferenceException: Arg_NullReferenceException
           at Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument[Int32](String argumentName)
        --- End of stack trace from previous location ---
           at Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument[Int32](String argumentName)
        --- End of stack trace from previous location ---
           at Xunit.Sdk.ReflectionAttributeInfo.GetNamedArgument[Int32](String argumentName)
           Exception_EndOfInnerExceptionStack
  info: Discovering: System.Buffers.Tests.dll (method display = ClassAndMethod, method display options = None)
  info: WASM EXIT 1
  fail: Application has finished with exit code TESTS_FAILED but 0 was expected
```

More info: dotnet#49770
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 18, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 18, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Codegen-AOT-mono untriaged New issue has not been triaged by the area owner
Projects
None yet
4 participants