Skip to content

Isolate.spawn is broken in snapshots when the original Dart file is missing #25430

Closed
@nex3

Description

@nex3

This breakage appears under the following conditions:

  • The script contains a package: import.
  • The script uses Isolate.spawn().
  • The script is run from a snapshot.
  • The original file that was snapshotted no longer exists.

To reproduce this, create a package with the following files:

// bin.dart
import 'dart:isolate';

main() async {
  await Isolate.spawn(entrypoint, null);
}

void entrypoint(_) {
}

Run:

$ dart --snapshot=bin.dart.snapshot bin.dart
$ rm bin.dart
$ dart bin.dart.snapshot

You should see an error like the following:

Unhandled exception:
Load Error for "file:///tmp/app/bin/bin.dart": Error loading file:///tmp/app/bin/bin.dart:
  FileSystemException: Cannot open file, path = '/tmp/app/bin/bin.dart' (OS Error: No such file or directory, errno = 2)
#0      _asyncLoadErrorCallback (dart:_builtin:155)
#1      _asyncLoadError (dart:_builtin:566)
#2      _handleLoaderReply (dart:_builtin:383)
#3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)

This is a regression. Running git bisect indicates that this error appeared as of 6d066c7. It's likely related to dart-lang/pub#1379.

Metadata

Metadata

Assignees

Labels

P0A serious issue requiring immediate resolutionarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)vm-regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions