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

pkg/dds/test/dap/integration/debug_attach_test fails on pkg-win-release-arm64 #55705

Open
aam opened this issue May 13, 2024 · 6 comments
Open
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. gardening P2 A bug or feature request we're likely to work on triaged Issue has been triaged by sub team

Comments

@aam
Copy link
Contributor

aam commented May 13, 2024

from logs


/============================================================================================\
| pkg/dds/test/dap/integration/debug_attach_test broke (Pass -> RuntimeError, expected Pass) |
\============================================================================================/

--- Command "vm" (took 19.000584s):
set DART_CONFIGURATION=ReleaseARM64 & set DART_SUPPRESS_WER=1 & out\ReleaseARM64\dart-sdk\bin\dart.exe --enable_asserts --sound-null-safety -Dtest_runner.configuration=unittest-asserts-release-win-arm64 --ignore-unrecognized-flags --packages=C:\opt\s\wh5ccbuqe\ir\cache\builder\sdk\.dart_tool\package_config.json C:\opt\s\wh5ccbuqe\ir\cache\builder\sdk\pkg\dds\test\dap\integration\debug_attach_test.dart

exit code:
255

stdout:
00:00 �[32m+0�[0m: debug mode can attach to a simple script using vmServiceUri�[0m

00:04 �[32m+1�[0m: debug mode can attach to a simple script using vmServiceInfoFile�[0m

00:08 �[32m+1�[0m�[31m -1�[0m: debug mode can attach to a simple script using vmServiceInfoFile �[1m�[31m[E]�[0m�[0m

  Instance of 'Response'

  

00:08 �[32m+1�[0m�[31m -1�[0m: debug mode removes breakpoints/pause and resumes on detach�[0m

00:13 �[32m+2�[0m�[31m -1�[0m: �[31mSome tests failed.�[0m



Consider enabling the flag chain-stack-traces to receive more detailed exceptions.
For example, 'dart test --chain-stack-traces'.

stderr:
Unhandled exception:
Dummy exception to set exit code.

--- Re-run this test:
python3 tools/test.py -n unittest-asserts-release-win-arm64 pkg/dds/test/dap/integration/debug_attach_test
@aam aam added area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. gardening labels May 13, 2024
@DanTup
Copy link
Collaborator

DanTup commented May 14, 2024

I'm seeing a slightly different error when I run locally (intermittently):

PS C:\Dev\Google\dart-sdk\sdk\pkg\dds> & 'C:\Dev\Tools\Dart\Latest (Bleeding Edge)\bin\dart.exe' .\test\dap\integration\debug_attach_test.dart
00:00 +0: debug mode can attach to a simple script using vmServiceUri

00:09 +0 -1: debug mode can attach to a simple script using vmServiceUri [E]

  SocketException: Write failed (OS Error: The pipe is being closed.
  , errno = 232), port = 0

  dart:io-patch/socket_patch.dart 1246:34       _NativeSocket.write
  dart:io-patch/socket_patch.dart 2004:15       _RawSocket.write
  dart:io-patch/socket_patch.dart 2481:18       _Socket._write
  dart:io-patch/socket_patch.dart 2216:28       _SocketStreamConsumer.write
  dart:io-patch/socket_patch.dart 2168:11       _SocketStreamConsumer.addStream.<fn>
  dart:async/zone.dart 1407:47                  _rootRunUnary
  dart:async/zone.dart 1308:19                  _CustomZone.runUnary

It's possible they're the same issue and there's just a timing difference causing it to show up differently. I'll debug/fix this and we can check the bot results after.

@DanTup DanTup self-assigned this May 14, 2024
@aam aam added triaged Issue has been triaged by sub team P2 A bug or feature request we're likely to work on labels May 14, 2024
@DanTup
Copy link
Collaborator

DanTup commented May 14, 2024

@bkonyi I can only reproduce the error above when running from the terminal - any time I run with a debugger it does not occur. My feeling is that when debugging, the timing is slightly different.

Unfortunately from the terminal, the stack trace is not very useful - there is no user code in it:

00:09 +0 -1: debug mode can attach to a simple script using vmServiceUri [E]

  SocketException: Write failed (OS Error: The pipe is being closed.
  , errno = 232), port = 0

  dart:io-patch/socket_patch.dart 1246:34       _NativeSocket.write
  dart:io-patch/socket_patch.dart 2004:15       _RawSocket.write
  dart:io-patch/socket_patch.dart 2481:18       _Socket._write
  dart:io-patch/socket_patch.dart 2216:28       _SocketStreamConsumer.write
  dart:io-patch/socket_patch.dart 2168:11       _SocketStreamConsumer.addStream.<fn>
  dart:async/zone.dart 1407:47                  _rootRunUnary
  dart:async/zone.dart 1308:19                  _CustomZone.runUnary
  dart:async/zone.dart 1217:7                   _CustomZone.runUnaryGuarded
  dart:async/stream_impl.dart 365:11            _BufferingStreamSubscription._sendData
  dart:async/stream_impl.dart 541:14            _DelayedData.perform
  dart:async/stream_impl.dart 646:11            _PendingEvents.handleNext
  dart:async/stream_impl.dart 617:7             _PendingEvents.schedule.<fn>
  dart:async/zone.dart 1391:47                  _rootRun
  dart:async/zone.dart 1301:19                  _CustomZone.run
  dart:async/zone.dart 1209:7                   _CustomZone.runGuarded
  dart:async/zone.dart 1249:23                  _CustomZone.bindCallbackGuarded.<fn>
  dart:async/zone.dart 1399:13                  _rootRun
  dart:async/zone.dart 1301:19                  _CustomZone.run
  dart:async/zone.dart 1209:7                   _CustomZone.runGuarded
  dart:async/zone.dart 1249:23                  _CustomZone.bindCallbackGuarded.<fn>
  dart:async/schedule_microtask.dart 40:21      _microtaskLoop
  dart:async/schedule_microtask.dart 49:5       _startMicrotaskLoop
  dart:isolate-patch/isolate_patch.dart 118:13  _runPendingImmediateCallback
  dart:isolate-patch/isolate_patch.dart 185:5   _RawReceivePort._handleMessage

Can you think of any ways I might be able to track down where this is happening? From the stack trace, I thought maybe I was using addStream somewhere, and the target stream is closed when the added stream gets an event, but I can't see any relevant addStream calls in the DAP code.

I don't know if something like the "asyncCausalFrames" we use via the VM Service would help here, but without reproducing with a debugger attached I'm not sure if I could get them to see.

Edit: I tried running with dart --observe --pause_isolates_on_unhandled_exceptions .\test\dap\integration\debug_attach_test.dart so I could attach a debugger, but seems like the exception was not unhandled (maybe the test package is catching it?) so it didn't pause there.

@aam
Copy link
Contributor Author

aam commented May 14, 2024

SocketException: Write failed (OS Error: The pipe is being closed.

This might be different race. This one is due to how during test session tearDown, client queues command "terminate" to the server's stdin, which races with server process itself shutting down first closing stdin socket, before that "terminate" command has a chance of being written into that server's stdin.

@DanTup
Copy link
Collaborator

DanTup commented May 15, 2024

This one is due to how during test session tearDown, client queues command "terminate" to the server's stdin, which races with server process itself shutting down first closing stdin socket, before that "terminate" command has a chance of being written into that server's stdin.

Move discussion of this to #55313 (comment)


As for the original issue here:

The Instance of 'Response' failure is when the debug adapter returns an error response. I will fix up this code so the reported error is clearer (includes the details of the response) so we can see what the adapter actually returned - my guess is that it's also related to the app shutting down so the request couldn't be fulfilled - which may or may not be similar to the error I'm seeing (hard to say without the specifics).

Edit: Opened https://dart-review.googlesource.com/c/sdk/+/366640 to improve the failure message.

copybara-service bot pushed a commit that referenced this issue May 15, 2024
This improves the failure messages that will show in tests if a DAP request unexpectedly fails.

Before:

```
Instance of 'Response'
```

After:

```
  Request "evaluate" failed:
  {
      "seq": 17,
      "type": "response",
      "body": {
          "error": {
              "format": "{message}",
              "id": 1,
              "showUser": true,
              "variables": {
                  "message": "This is a test failure",
                  "stack": "#0      DartDebugAdapter.evaluateRequest (package:dds/src/dap/adapters/dart.dart:1046:5)\n#1      (SNIP)\n"
              }
          }
      },
      "command": "evaluate",
      "message": "This is a test failure",
      "request_seq": 8,
      "success": false
  }
```

Might help diagnose #55705.

Change-Id: If9edad16090a8bd09e22dd9b772401763d281f8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366640
Commit-Queue: Helin Shiah <[email protected]>
Reviewed-by: Ben Konyi <[email protected]>
Reviewed-by: Helin Shiah <[email protected]>
@sstrickl
Copy link
Contributor

sstrickl commented May 16, 2024

Here's an example failure from one of the logs after this change:

00:14 �[32m+8�[0m�[31m -1�[0m: debug mode evaluation returns the full message for evaluation errors �[1m�[31m[E]�[0m�[0m

  Expected: throws <Instance of 'Response'> with `success`: false and `message`: (contains 'evaluateInFrame: (113) Expression compilation error' and contains '\'String\' can\'t be assigned to a variable of type \'num\'.' and contains '1 + "a"\n'
              '    ^')
    Actual: <Instance of 'Future<Response>'>
     Which: threw RequestException:<Request "evaluate" failed:
                  {
                      "seq": 17,
                      "type": "response",
                      "body": {
                          "error": {
                              "format": "{message}",
                              "id": 1,
                              "showUser": true,
                              "variables": {
                                  "message": "evaluateInFrame: (113) Expression compilation error\norg-dartlang-debug:synthetic_debug_expression:1:5: Error: A value of type 'String' can't be assigned to a variable of type 'num'.\n1 + \"a\"\n    ^",
                                  "stack": "#0      DartDebugAdapter.evaluateRequest (package:dds/src/dap/adapters/dart.dart:1127:7)\n<asynchronous suspension>\n#1      BaseDebugAdapter.handle (package:dds/src/dap/base_debug_adapter.dart:141:7)\n<asynchronous suspension>\n"
                              }
                          }
                      },
                      "command": "evaluate",
                      "message": "evaluateInFrame: (113) Expression compilation error\norg-dartlang-debug:synthetic_debug_expression:1:5: Error: A value of type 'String' can't be assigned to a variable of type 'num'.\n1 + \"a\"\n    ^",
                      "request_seq": 8,
                      "success": false
                  }>
            stack 
            which is not an instance of 'Response'

@DanTup
Copy link
Collaborator

DanTup commented May 16, 2024

@sstrickl that's actually a different issue that was caused by my change :-( Unfortunately I don't think the right trybots ran on https://dart-review.googlesource.com/c/sdk/+/366640 so it wasn't stopped. I've opened a fix for that at https://dart-review.googlesource.com/c/sdk/+/366665

That issue shouldn't affect this test though - if debug_attach_test fails we should get a more detailed error like that, although I'm struggling to find if it is currently failing (I tried https://dart-ci.firebaseapp.com/#showLatestFailures=false&configurations=pkg-win-release-arm64 and don't see it, but I don't know if approved failures appear there?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. gardening P2 A bug or feature request we're likely to work on triaged Issue has been triaged by sub team
Projects
None yet
Development

No branches or pull requests

3 participants