Closed
Description
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 apackages/
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
iposva-google commentedon Jan 20, 2016
Fixed: https://codereview.chromium.org/1591573004
iposva-google commentedon Jan 20, 2016
Duplicate of #25430