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

Invalid argument(s): Uri org-dartlang-sdk:///lib/_internal/js_dev_runtime/private/ddc_runtime/rtti.dart must have scheme 'file:'. #43589

Closed
alextekartik opened this issue Sep 28, 2020 · 14 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dev-compiler

Comments

@alextekartik
Copy link

I have a github project that started failing on the beta branch since Dart SDK version: 2.10.0-110.5.beta

https://travis-ci.org/github/tekartik/browser_utils.dart/jobs/730257382

The command:

pub run build_runner test -- -p chrome

The error:

Error compiling dartdevc module:tekartik_browser_utils|test/js_utils_browser_test.unsound.ddc.js
We're sorry, you've found a bug in our compiler.
You can report this bug at:
    https://github.com/dart-lang/sdk/issues/labels/web-dev-compiler
Please include the information below in your report, along with
any other information that may help us track it down. Thanks!
-------------------- %< --------------------
    dartdevc -k arguments: --dart-sdk-summary=/home/travis/dart-sdk/lib/_internal/ddc_sdk.dill --modules=amd --no-summarize -o test/js_utils_browser_test.unsound.ddc.js --source-map --summary=packages/js/js.unsound.ddc.dill=packages/js/js --summary=packages/js/js_util.unsound.ddc.dill=packages/js/js_util --summary=test/data/js_binding.unsound.ddc.dill=test/data/js_binding --summary=packages/synchronized/src/utils.unsound.ddc.dill=packages/synchronized/src/utils --summary=packages/synchronized/synchronized.unsound.ddc.dill=packages/synchronized/synchronized --summary=packages/tekartik_common_utils/list_utils.unsound.ddc.dill=packages/tekartik_common_utils/list_utils --summary=packages/tekartik_common_utils/async_utils.unsound.ddc.dill=packages/tekartik_common_utils/async_utils --summary=packages/tekartik_browser_utils/src/js_utils/js_converter.unsound.ddc.dill=packages/tekartik_browser_utils/src/js_utils/js_converter --summary=packages/tekartik_browser_utils/js_utils.unsound.ddc.dill=packages/tekartik_browser_utils/js_utils --summary=packages/path/path.unsound.ddc.dill=packages/path/path --summary=packages/stack_trace/src/chain.unsound.ddc.dill=packages/stack_trace/src/chain --summary=packages/matcher/src/core_matchers.unsound.ddc.dill=packages/matcher/src/core_matchers --summary=packages/matcher/matcher.unsound.ddc.dill=packages/matcher/matcher --summary=packages/meta/meta.unsound.ddc.dill=packages/meta/meta --summary=packages/collection/src/utils.unsound.ddc.dill=packages/collection/src/utils --summary=packages/collection/src/algorithms.unsound.ddc.dill=packages/collection/src/algorithms --summary=packages/collection/src/iterable_zip.unsound.ddc.dill=packages/collection/src/iterable_zip --summary=packages/collection/src/comparators.unsound.ddc.dill=packages/collection/src/comparators --summary=packages/collection/src/priority_queue.unsound.ddc.dill=packages/collection/src/priority_queue --summary=packages/collection/src/canonicalized_map.unsound.ddc.dill=packages/collection/src/canonicalized_map --summary=packages/collection/collection.unsound.ddc.dill=packages/collection/collection --summary=packages/test_api/src/util/iterable_set.unsound.ddc.dill=packages/test_api/src/util/iterable_set --summary=packages/charcode/ascii.unsound.ddc.dill=packages/charcode/ascii --summary=packages/charcode/html_entity.unsound.ddc.dill=packages/charcode/html_entity --summary=packages/charcode/charcode.unsound.ddc.dill=packages/charcode/charcode --summary=packages/term_glyph/src/generated/ascii_glyph_set.unsound.ddc.dill=packages/term_glyph/src/generated/ascii_glyph_set --summary=packages/source_span/source_span.unsound.ddc.dill=packages/source_span/source_span --summary=packages/string_scanner/src/eager_span_scanner.unsound.ddc.dill=packages/string_scanner/src/eager_span_scanner --summary=packages/async/async.unsound.ddc.dill=packages/async/async --summary=packages/boolean_selector/boolean_selector.unsound.ddc.dill=packages/boolean_selector/boolean_selector --summary=packages/stream_channel/stream_channel.unsound.ddc.dill=packages/stream_channel/stream_channel --summary=packages/test_api/src/backend/metadata.unsound.ddc.dill=packages/test_api/src/backend/metadata --summary=packages/test_api/src/backend/closed_exception.unsound.ddc.dill=packages/test_api/src/backend/closed_exception --summary=packages/test_core/src/runner/coverage_stub.unsound.ddc.dill=packages/test_core/src/runner/coverage_stub --summary=packages/pool/pool.unsound.ddc.dill=packages/pool/pool --summary=packages/test_api/backend.unsound.ddc.dill=packages/test_api/backend --summary=packages/pedantic/pedantic.unsound.ddc.dill=packages/pedantic/pedantic --summary=packages/test_core/test_core.unsound.ddc.dill=packages/test_core/test_core --summary=packages/test/test.unsound.ddc.dill=packages/test/test --summary=packages/dev_test/test.unsound.ddc.dill=packages/dev_test/test --packages=.dart_tool/package_config.json --module-name=test/js_utils_browser_test --multi-root-scheme=org-dartlang-app --multi-root=. --track-widget-creation --inline-source-map --libraries-file=file:///home/travis/dart-sdk/lib/libraries.json --experimental-emit-debug-metadata --used-inputs-file=/tmp/ddk_builder_UGTMKS/used_inputs.txt test/js_utils_browser_test.dart --no-sound-null-safety
    dart --version: 2.10.0-110.5.beta (beta) (Wed Sep 23 11:05:07 2020 +0200) on "linux_x64"
Invalid argument(s): Uri org-dartlang-sdk:///lib/_internal/js_dev_runtime/private/ddc_runtime/rtti.dart must have scheme 'file:'.
#0      PosixStyle.pathFromUri (package:path/src/style/posix.dart:57:5)
#1      Context.fromUri (package:path/src/context.dart:1000:32)
#2      fromUri (package:path/path.dart:417:32)
#3      placeSourceMap.makeRelative (package:dev_compiler/src/compiler/shared_command.dart:421:45)
#4      placeSourceMap (package:dev_compiler/src/compiler/shared_command.dart:431:27)
#5      jsProgramToCode (package:dev_compiler/src/kernel/command.dart:662:16)
#6      _compile (package:dev_compiler/src/kernel/command.dart:438:18)
<asynchronous suspension>
#7      compile (package:dev_compiler/src/kernel/command.dart:46:18)
#8      compile (package:dev_compiler/src/compiler/shared_command.dart:454:10)
#9      _CompilerWorker.performRequest.<anonymous closure> (file:///b/s/w/ir/cache/builder/sdk/pkg/dev_compiler/bin/dartdevc.dart:77:13)
#10     _rootRun (dart:async/zone.dart:1190:13)
#11     _CustomZone.run (dart:async/zone.dart:1093:19)
#12     _runZoned (dart:async/zone.dart:1630:10)
#13     runZoned (dart:async/zone.dart:1550:10)
#14     _CompilerWorker.performRequest (file:///b/s/w/ir/cache/builder/sdk/pkg/dev_compiler/bin/dartdevc.dart:75:24)
#15     AsyncWorkerLoop.run.<anonymous closure> (package:bazel_worker/src/worker/async_worker_loop.dart:35:41)
#16     _rootRun (dart:async/zone.dart:1190:13)
#17     _CustomZone.run (dart:async/zone.dart:1093:19)
#18     _runZoned (dart:async/zone.dart:1630:10)
#19     runZoned (dart:async/zone.dart:1550:10)
#20     AsyncWorkerLoop.run (package:bazel_worker/src/worker/async_worker_loop.dart:35:26)
<asynchronous suspension>
#21     main (file:///b/s/w/ir/cache/builder/sdk/pkg/dev_compiler/bin/dartdevc.dart:29:57)
#22     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:32)
#23     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

It worked fine on 2.10.0-110.3.beta: https://travis-ci.org/github/tekartik/browser_utils.dart/jobs/728330156

It also works fine on the stable branch.

It fails consistently which is why I reported it.

@alextekartik
Copy link
Author

alextekartik commented Sep 28, 2020

I wanted to add the label web-dev-compiler as suggested but could not...

@mit-mit mit-mit added area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dev-compiler labels Sep 30, 2020
@nshahan
Copy link
Contributor

nshahan commented Sep 30, 2020

@jakemac53 Do you think this is a build_web_compilers issue?

@jakemac53
Copy link
Contributor

This error essentially means I believe that it tried and failed to read the file lib/_internal/js_dev_runtime/private/ddc_runtime/rtti.dart from the SDK. I don't know if it is expected that it would try to read that file?

When the multi-root file system fails to find a file, I believe it then tries to delegate the read to the standard file system, which then throws this error because it doesn't support that scheme.

@nshahan
Copy link
Contributor

nshahan commented Sep 30, 2020

@alextekartik I wasn't able to reproduce this issue locally. I have Dart SDK 2.10.0-110.5.beta and I checked out your repo https://github.com/tekartik/browser_utils.dart at master. Have you reproduced this on your local machine or only on travis?

@alextekartik
Copy link
Author

@nshahan It seems to happen only on travis which indeed is a pain. I think it comes from this project (https://github.com/tekartik/js_utils.dart/tree/master/js_utils) which also fails with the same error:

https://travis-ci.org/github/tekartik/js_utils.dart/jobs/731662766

It worked on 2.10.0-110.3.beta and fails consistently on 2.10.0-110.5.beta without change. If I get time I will try to remove code from it (it is a small js interop project) to get a minimum reproducible scenario if that could be helpfull

alextekartik added a commit to tekartikdev/js_utils.dart that referenced this issue Sep 30, 2020
alextekartik added a commit to tekartikdev/js_utils.dart that referenced this issue Sep 30, 2020
alextekartik added a commit to tekartikdev/js_utils.dart that referenced this issue Sep 30, 2020
@nshahan
Copy link
Contributor

nshahan commented Sep 30, 2020

If I get time I will try to remove code from it (it is a small js interop project) to get a minimum reproducible scenario if that could be helpfull

Thanks! Ideally a minimal repro that displays the issue locally would be the best.

@alextekartik
Copy link
Author

Ok the smallest I came too was the creation of an anonymous JS object such as this one:

@JS()
@anonymous
class WithIntValue {
  external int get value;
  external set value(int value);
  external factory WithIntValue({int value});
}

Just adding:

var withIntValue = WithIntValue();

in a unit test make the test (well...the compilation) fails on travis with the same reported error. I remember having a similar issue once on my linux box but I cannot reproduce it...

Minimum repro travis job: https://travis-ci.org/github/tekartikdev/js_utils.dart/builds/731779145
Minimum repro source: https://github.com/tekartikdev/js_utils.dart/tree/master/js_utils

In the mean time my workaround is to not call pub run build_runner test -- -p chrome on travis. Debugging works fine in the browser and pub run test -p chrome does succeed to do some validation on the code. So no urgent blocking point for. Maybe the issue is in travis, maybe in my code (but the code above is about all I have). Maybe it will raise as another issue in the future. Thanks for taking the time to investigate and I don't any have good reproducible scenario that can be debug in a good way.

alextekartik added a commit to tekartik/dev_test.dart that referenced this issue Oct 1, 2020
@nshahan
Copy link
Contributor

nshahan commented Oct 1, 2020

@jakemac53 Is there anything you see in the travis logs from above that stands out as being different than what you would get locally?

@jakemac53
Copy link
Contributor

jakemac53 commented Oct 1, 2020

I don't see anything obvious, no :(. I also tried to locally repro using exactly that version of the sdk that travis used and couldn't repro it with that either.

@nshahan
Copy link
Contributor

nshahan commented Oct 1, 2020

Progress update:

@jakemac53 and I were investigating and were able to reproduce it locally but only very rarely. This suggests there is a timing issue that is triggered more consistently when running on travis. When it did actually fail we were able to determine that the cause of the crash is the contents of the source maps. It appears that a file from the SDK is included in the sources for the module being compiled. See:

{version: 3, sourceRoot: , sources: [test/js_utils_test.dart, org-dartlang-sdk:///lib/_internal/js_dev_runtime/private/ddc_runtime/rtti.dart], names: [], mappings: ;;;;;;;;;;AAOsB,IAApB,eAAK,SAAS;;AAaZ,IAXF,gBAAM,YAAY;AAUd,MATF,eAAK,aAAa;AAQZ,2BCmIE;;;EDhIZ, file: file://test/js_utils_test.unsound.ddc.js}

We have ideas to work around the issue and avoid crashing but would like to find the root cause. It is unexpected that the sources from the SDK should be included here and suggests that for some reason the file from the SDK is being compiled within a module unnecessarily.

@nshahan
Copy link
Contributor

nshahan commented Oct 3, 2020

Progress update:

We have identified the reason this is hard to reproduce. The ddc worker that compiles the SDK module must also compile the module with the repro in it. Travis jobs run with fewer workers so it is more likely to happen than on a local build. You can reproduce locally by setting an environment variable before running the build BUILD_MAX_WORKERS_PER_TASK=1.

I have a potential fix in progress. The issue is caused by a cache of templates used to create JS code that can contain sourcemap information. If they have that information they should not be cached.

@alextekartik
Copy link
Author

@nshahan Thanks for the progress. I'm definitely getting this issue from time to time on my linux box. I'll be happy to help you in testing your solution. Good luck!

@greglittlefield-wf
Copy link
Contributor

It looks like you guys have this figured already, but in case another example of the issue is helpful, here's a case where I saw it in Travis on the react package in Dart 2.10.0 stable: https://travis-ci.com/github/cleandart/react-dart/jobs/395369663

@nshahan
Copy link
Contributor

nshahan commented Oct 5, 2020

@greglittlefield-wf Thanks for another example. Funny timing, I just sent a fix out for review. We are discussing the right way to distribute it still.

Although the bug exists in the Dart SDK, as a temporary work around you can avoid triggering it by using a version of build_web_compilers <= 2.11.0.

dart-bot pushed a commit that referenced this issue Oct 13, 2020
JS templates should always use their own source information. DDC
was incorrectly caching and reusing templates with the same source
information in various parts of the program. This lead to incorrect
source maps and in some cases compiler crashes when the source map
in a user application pointed to source location in the SDK.

Change-Id: I11607e6f02b894ead1d350e9b3071173ba36a048
Fixes: #43589
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166122
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dev-compiler
Projects
None yet
Development

No branches or pull requests

5 participants