dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.1k stars 1.56k forks source link

VM stack trace for async computatation not complete enough. #56787

Open ekuleshov opened 2 hours ago

ekuleshov commented 2 hours ago

Using the following snippet of code and assuming no file "aaa" is available:

Future<void> main() async {
  var file = File('aaa');
  Stream<List<int>> data = file.openRead();
  await data.listen((value) {}).asFuture();
}

It throws an exception with the following stacktrace

Unhandled exception:
PathNotFoundException: Cannot open file, path = 'aaa' (OS Error: No such file or directory, errno = 2)
#0      _checkForErrorResponse (dart:io/common.dart:55:9)
#1      _File.open.<anonymous closure> (dart:io/file_impl.dart:381:7)
<asynchronous suspension>
#2      _FileStream._start.onOpenFile (dart:io/file_impl.dart:153:5)
<asynchronous suspension>

As you can see, the stacktrace does not have the source pointer, i.e. the above File.openRead() call in the main() method. The same issue with File.openWrite() call.

This is similar to another async io stackterace issue as noted in https://github.com/dart-lang/sdk/issues/56431#issuecomment-2374041769

The above exceptions are from macos, but I've been getting similar errors from the user devices running iOS and Android and it is making it hard to track these issues back to the source code.

dart-github-bot commented 2 hours ago

Summary: The user is experiencing a PathNotFoundException when attempting to open a non-existent file using File.openRead(). The stack trace lacks source pointers, making it difficult to pinpoint the exact location of the error in the user's code. This issue is similar to a previously reported issue and affects multiple platforms, including macOS, iOS, and Android.