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][debugger] Fix some flaky tests #64652

Merged
merged 3 commits into from
Feb 2, 2022
Merged

Conversation

radical
Copy link
Member

@radical radical commented Feb 1, 2022

Fixes #64483
Fixes #63560

The test fails sometimes with:

```
[02:40:04] dbug: Inspector-3[0] Failing all waiters because: Runtime.exceptionThrown: {   "timestamp": 1643683204929.399,   "exceptionDetails": {     "exceptionId": 2,     "text": "Uncaught",     "lineNumber": 0,     "columnNumber": 31,     "scriptId": "32",     "stackTrace": {       "callFrames": [         {           "functionName": "",           "scriptId": "32",           "url": "",           "lineNumber": 0,           "columnNumber": 31         }       ]     },     "exception": {       "type": "object",       "subtype": "error",       "className": "ReferenceError",       "description": "ReferenceError: non_existant_fn is not defined\n    at <anonymous>:1:32",       "objectId": "1487416918028189685.1.57",       "preview": {         "type": "object",         "subtype": "error",         "description": "ReferenceError: non_existant_fn is not defined\n    at <anonymous>:1:32",         "overflow": false,         "properties": [           {             "name": "stack",             "type": "string",             "value": "ReferenceError: non_existant_fn is not defined\n    at <anonymous>:1:32"           },           {             "name": "message",             "type": "string",             "value": "non_existant_fn is not defined"           }         ]       }     },     "executionContextId": 1   } }

[02:41:02] dbug: InspectorClient-3[0] Socket is no longer open
[02:41:02] dbug: InspectorClient-3[0] RunLoop stopped, reason: Cancelled. (parentToken: True, linked: True):
[02:41:02] dbug: InspectorClient-3[0] Failing 0 pending cmds
[02:41:02] dbug: InspectorClient-3[0] Loop ended with socket: Aborted
[02:41:03] dbug: InspectorClient-4[0] connecting to ws://localhost:9400/launch-chrome-and-connect/?test_id=4

[xUnit.net 00:02:07.56]     DebuggerTests.HarnessTests.ExceptionThrown [FAIL]
[02:41:03] info: Microsoft.WebAssembly.Diagnostics.TestHarnessProxy[0] [testId: 4] New test request for test id 4
  Failed DebuggerTests.HarnessTests.ExceptionThrown [58 s]
  Error Message:
   Assert.Throws() Failure
Expected: typeof(System.ArgumentException)
Actual:   typeof(System.Threading.Tasks.TaskCanceledException): Test timed out (elapsed time: 60.0062617)
---- System.Threading.Tasks.TaskCanceledException : Test timed out (elapsed time: 60.0062617)
  Stack Trace:
     at DebuggerTests.DebuggerTestBase.SendCommandAndCheck(JObject args, String method, String script_loc, Int32 line, Int32 column, String function_name, Func`2 wait_for_event_fn, Func`2 locals_fn, String waitForEvent) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 523
   at DebuggerTests.DebuggerTestBase.EvaluateAndCheck(String expression, String script_loc, Int32 line, Int32 column, String function_name, Func`2 wait_for_event_fn, Func`2 locals_fn) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 507
   at DebuggerTests.HarnessTests.<ExceptionThrown>b__1_0() in /_/src/mono/wasm/debugger/DebuggerTestSuite/HarnessTests.cs:line 30
----- Inner Stack Trace -----
   at DebuggerTests.DebuggerTestBase.SendCommandAndCheck(JObject args, String method, String script_loc, Int32 line, Int32 column, String function_name, Func`2 wait_for_event_fn, Func`2 locals_fn, String waitForEvent) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 523
   at DebuggerTests.DebuggerTestBase.EvaluateAndCheck(String expression, String script_loc, Int32 line, Int32 column, String function_name, Func`2 wait_for_event_fn, Func`2 locals_fn) in /_/src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs:line 507
   at DebuggerTests.HarnessTests.<ExceptionThrown>b__1_0() in /_/src/mono/wasm/debugger/DebuggerTestSuite/HarnessTests.cs:line 30
```

The test uses `SendCommand` to evaluate
    `("window.setTimeout(function() { non_existant_fn(); }, 1)`
which tries to invoke the `non_existant_fn` after 1ms. This causes a
`Runtime.exceptionThrown` event message to be received, and the
`Inspector` fails any waiters (eg. `insp.WaitFor(READY)`).

So we have:

1. SendCommand
2. insp.WaitFor

But the `Runtime.exceptionThrown` can be received before we get to (2),
thus the waiter from (2) never gets failed, and instead times out.
This is an inherently racy test because we might get the socket closed
exception first, or the ArgumentException for the cdp events. And
effectively, it's not a useful test.
`ArrayTests.InvalidValueTypeArrayIndex` isn't needed any more because
array members don't have special ids now.

Fixes dotnet#63560
@radical radical requested review from lewing and removed request for marek-safar February 1, 2022 23:35
@radical radical requested a review from thaystg February 1, 2022 23:35
@ghost ghost assigned radical Feb 1, 2022
@radical radical added the arch-wasm WebAssembly architecture label Feb 1, 2022
@ghost
Copy link

ghost commented Feb 1, 2022

Tagging subscribers to this area: @thaystg
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #64483
Fixes #63560

Author: radical
Assignees: -
Labels:

area-Debugger-mono

Milestone: -

@radical radical changed the title [wasm][debugger] Fix some tests [wasm][debugger] Fix some flaky tests Feb 1, 2022
@radical
Copy link
Member Author

radical commented Feb 1, 2022

@thaystg The updated ArrayTests.InvalidArrayId tries to access an object as an array by using dotnet:array:{non-array-id}, and that causes an assertion:

[18:36:49] info: DebuggerTests.Inspector[0] console.trace: * Assertion at /Users/radical/dev/r3/src/mono/mono/metadata/class.c:4580, condition `m_class_get_rank (ac)' not met
[18:36:49] info: DebuggerTests.Inspector[0] console.error: * Assertion at /Users/radical/dev/r3/src/mono/mono/metadata/class.c:4580, condition `m_class_get_rank (ac)' not met

Can we return an error instead?

@radical radical merged commit 3a77a6d into dotnet:main Feb 2, 2022
@radical radical deleted the fix-dbg-tests branch February 2, 2022 19:25
@ghost ghost locked as resolved and limited conversation to collaborators Mar 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Debugger-mono
Projects
None yet
2 participants