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.27k stars 1.58k forks source link

DDC / Incremental Compilation problems #38102

Open vsmenon opened 5 years ago

vsmenon commented 5 years ago

We still have several reports of errors in the wild where DDC (kernel-based) crashes on invalid kernel input when invoking initializeIncrementalCompiler:

RangeError (index): Index out of range: no indices are valid: 0
#0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2188:7)
#1      BinaryBuilder.readByte (package:kernel/binary/ast_from_binary.dart:100:27)
#2      BinaryBuilder.readUint32 (package:kernel/binary/ast_from_binary.dart:120:13)
#3      BinaryBuilder.readComponent (package:kernel/binary/ast_from_binary.dart:440:17)
#4      ProcessedOptions.loadComponent (package:front_end/src/base/processed_options.dart:392:10)
#5      initializeIncrementalCompiler (package:front_end/src/api_unstable/ddc.dart:233:14)
<asynchronous suspension>

Or for example:

Bad state: Empty input given.
#0 BinaryBuilder._checkEmptyInput (package:kernel/binary/ast_from_binary.dart:457:29)
#1 BinaryBuilder.readComponent. (package:kernel/binary/ast_from_binary.dart:474:7)
#2 Timeline.timeSync (dart:developer/timeline.dart:161:22)
#3 BinaryBuilder.readComponent (package:kernel/binary/ast_from_binary.dart:472:21)
#4 ProcessedOptions.loadComponent (package:front_end/src/base/processed_options.dart:410:10)
#5 initializeIncrementalCompiler (package:front_end/src/api_unstable/modular_incremental_compilation.dart:207:29)

See https://github.com/dart-lang/build/issues/2362

@natebosch @jakemac53 - should we catch and return a specific error code from DDC for this?

fyi @jensjoha

jakemac53 commented 4 years ago

Hard to say - we aren't actively working on it, but haven't "fixed" it as far as we know. The primary users hitting it were flutter web users who don't seem to be reporting it any more but most of them have moved off of build_web_compilers now.

Leaving it open makes it more discoverable, which is nice.

jakemac53 commented 4 years ago

Removing myself as the assignee since there is no ongoing work here

lejard-h commented 4 years ago

For others that are experiencing this problem you can also try using the master branch of flutter which uses a different compilation strategy and shouldn't have this problem. It isn't completely polished yet (source_maps/debugging are in a state of flux) but it should be improving quickly.

Is it something that should still happen on an Angular app ? Happens a lot when merging a branch while webdev serve is running

Dart: 2.10.2 Angular: 6.0.0 build_web_compiler: 2.11.0

jakemac53 commented 4 years ago

Angular does still use this code path and may still experience this issue

parren-google commented 3 years ago

I can repro this by updating back and forth between revisions. I could send more info @google if you're interested. Using Angular.

jodinathan commented 2 years ago

We get this from time to time:

build_web_compilers:ddc on lib/routes/login/login.template.ddc.module:
Failed to initialize incremental compiler, throwing away old state.

This is likely a result of https://github.com/dart-lang/sdk/issues/38102, if
you are consistently seeing this problem please see that issue.

The specific exception that was encountered was:

type 'Field' is not a subtype of type 'Procedure?' in type cast
#0      BinaryBuilder.readProcedure (package:kernel/binary/ast_from_binary.dart:1674:38)
#1      BinaryBuilder._readProcedureList.<anonymous closure> (package:kernel/binary/ast_from_binary.dart:1248:14)
#2      new List.generate (dart:core-patch/array_patch.dart:64:28)
#3      BinaryBuilder._readProcedureList (package:kernel/binary/ast_from_binary.dart:1246:32)
#4      BinaryBuilder.readClassPartialContent (package:kernel/binary/ast_from_binary.dart:1511:31)
#5      BinaryBuilder.readClass (package:kernel/binary/ast_from_binary.dart:1403:7)
#6      BinaryBuilder._readClassList.<anonymous closure> (package:kernel/binary/ast_from_binary.dart:1207:16)
#7      new List.generate (dart:core-patch/array_patch.dart:64:28)
#8      BinaryBuilder._readClassList (package:kernel/binary/ast_from_binary.dart:1205:37)
#9      BinaryBuilder.readLibrary (package:kernel/binary/ast_from_binary.dart:1175:5)
#10     BinaryBuilder._readOneComponent (package:kernel/binary/ast_from_binary.dart:873:9)
#11     BinaryBuilder.readComponent.<anonymous closure> (package:kernel/binary/ast_from_binary.dart:657:34)
#12     Timeline.timeSync (dart:developer/timeline.dart:157:22)
#13     BinaryBuilder.readComponent (package:kernel/binary/ast_from_binary.dart:627:21)
#14     ProcessedOptions.loadComponent (package:front_end/src/base/processed_options.dart:467:10)
#15     initializeIncrementalCompiler (package:front_end/src/api_unstable/modular_incremental_compilation.dart:210:33)
<asynchronous suspension>
#16     _compile (package:dev_compiler/src/kernel/command.dart:300:21)
<asynchronous suspension>
#17     compile (package:dev_compiler/src/kernel/command.dart:50:12)
<asynchronous suspension>
#18     _CompilerWorker.performRequest (package:dev_compiler/ddc.dart:68:18)
<asynchronous suspension>
#19     AsyncWorkerLoop.run (package:bazel_worker/src/worker/async_worker_loop.dart:35:20)
<asynchronous suspension>
#20     internalMain (package:dev_compiler/ddc.dart:31:5)
<asynchronous suspension>
jakemac53 commented 2 years ago

@jodinathan that looks like https://github.com/dart-lang/sdk/issues/49261 which should be resolved at head

parren-google commented 1 year ago

Still happening with dart-dev-runner occasionally.

natebosch commented 1 year ago

@parren-google - can you file a buganizer with the stack trace and reproduction instructions for surfacing this issue with dart-dev-runner?