Skip to content

Isolate.spawn is broken in snapshots when the original .packages file is missing #25429

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

Closed
nex3 opened this issue Jan 14, 2016 · 2 comments
Closed
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P0 A serious issue requiring immediate resolution type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) vm-regression
Milestone

Comments

@nex3
Copy link
Member

nex3 commented Jan 14, 2016

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 directory containing the snapshot has neither a .packages file nor a packages/ directory.

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

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

import 'package:app/app.dart';

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

void entrypoint(_) {
}
// lib/app.dart

// This file can be empty.
# pubspec.yaml
name: app

Run:

$ pub get
$ dart --snapshot=bin.dart.snapshot bin/bin.dart
$ rm .packages
$ rm -r packages/
$ dart bin.dart.snapshot

You should see an error like the following:

Unhandled exception:
IsolateSpawnException: Unable to spawn isolate: Unhandled exception:
Load Error for "package:app/app.dart": Could not resolve a package location for base at file:///tmp/app/bin/bin.dart
#0      _asyncLoadErrorCallback (dart:_builtin:155)
#1      _asyncLoadError (dart:_builtin:566)
#2      _loadPackage (dart:_builtin:605)
#3      _loadPackage.<anonymous closure> (dart:_builtin:621)
#4      _handlePackagesReply (dart:_builtin:464)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
#0      Isolate.spawn.<spawn_async_body> (dart:isolate-patch/isolate_patch.dart)
#1      _asyncErrorWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:34)
#2      _RootZone.runBinary (dart:async/zone.dart:1154)
#3      _Future._propagateToListeners.handleError (dart:async/future_impl.dart:579)
#4      _Future._propagateToListeners (dart:async/future_impl.dart:641)
#5      _Future._completeError (dart:async/future_impl.dart:432)
#6      _SyncCompleter._completeError (dart:async/future_impl.dart:56)
#7      _Completer.completeError (dart:async/future_impl.dart:27)
#8      Isolate._spawnCommon.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:413)
#9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)

It's worth noting that the error is the same regardless of whether the snapshot file is copied to, indicating that it somehow remembers its original location. It's not clear why this is, and it could be construed as a security risk if the file system path of the build system is sensitive for some reason.

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

@iposva-google
Copy link
Contributor

@iposva-google
Copy link
Contributor

Duplicate of #25430

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Type-Defect labels Mar 1, 2016
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, and the AOT and JIT backends. P0 A serious issue requiring immediate resolution type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) vm-regression
Projects
None yet
Development

No branches or pull requests

3 participants