flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.19k stars 27.49k forks source link

Compilation error with hot restart leads to crash #27120

Closed dnfield closed 5 years ago

dnfield commented 5 years ago

Reproduction steps:

Run a valid flutter app.

Edit the app to have a syntax error (e.g. extra/misplaced comma or paren).

Hot restart.

See error in console:

Your application could not be compiled, because its dependencies could not be established.
When trying to parse this Dart file to find its dependencies:
  /Users/dnfield/src/flutter/packages/flutter/lib/src/rendering/proxy_box.dart
...the analyzer failed with the following error:
  Error in /Users/dnfield/src/flutter/packages/flutter/lib/src/rendering/proxy_box.dart: Expected to find ')'.
Performing hot restart...                                               
Try again after fixing the above error(s).

Compiler message:
result adf42e8d-513e-4fc0-9ab4-20901e5b0e62
adf42e8d-513e-4fc0-9ab4-20901e5b0e62

Fix error, hot restart again:

Unhandled exception:                                                    
Crash when compiling package:flutter/material.dart,                     
at character offset null:                                               
RangeError (offset): Invalid value: Not in range 0..1387, inclusive: 1536
#0      RangeError.checkValueInInterval (dart:core/errors.dart:281:7)   
#1      Source.getLocation (package:kernel/ast.dart:5793:16)            
#2      getLocation (package:front_end/src/fasta/messages.dart:16:52)   
#3      ProcessedOptions.format (package:front_end/src/base/processed_options.dart:192:47)
#4      ProcessedOptions.report (package:front_end/src/base/processed_options.dart:216:43)
#5      CompilerContext.report (package:front_end/src/fasta/compiler_context.dart:68:13)
#6      Loader.addMessage (package:front_end/src/fasta/loader.dart:274:20)
#7      Loader.addProblem (package:front_end/src/fasta/loader.dart:225:12)
#8      LibraryBuilder.addProblem (package:front_end/src/fasta/builder/library_builder.dart:109:19)
#9      KernelLibraryBuilder.addProblem (package:front_end/src/fasta/kernel/kernel_library_builder.dart:250:47)
#10     KernelLibraryBuilder.reportTypeArgumentIssue (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1512:5)
#11     KernelLibraryBuilder.reportTypeArgumentIssues (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1497:7)
#12     KernelLibraryBuilder.checkBoundsInType (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1620:7)
#13     KernelLibraryBuilder.checkBoundsInField (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1517:5)
#14     KernelClassBuilder.checkBoundsInOutline (package:front_end/src/fasta/kernel/kernel_class_builder.dart:387:15)
#15     KernelLibraryBuilder.checkBoundsInOutline (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1753:21)
#16     SourceLoader.checkBounds.<anonymous closure> (package:front_end/src/fasta/source/source_loader.dart:854:16)
#17     __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:367:8)
#18     SourceLoader.checkBounds (package:front_end/src/fasta/source/source_loader.dart:850:14)
#19     KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:265:14)
<asynchronous suspension>                                               
#20     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>                                               
#21     KernelTarget.buildOutlines (package:front_end/src/fasta/kernel/kernel_target.dart:238:12)
<asynchronous suspension>                                               
#22     IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:254:22)
<asynchronous suspension>                                               
#23     CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:46)
#24     new Future.sync (dart:async/future.dart:224:31)                 
#25     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:19)
#26     _rootRun (dart:async/zone.dart:1124:13)                         
#27     _CustomZone.run (dart:async/zone.dart:1021:19)                  
#28     _runZoned (dart:async/zone.dart:1516:10)                        
#29     runZoned (dart:async/zone.dart:1463:12)                         
#30     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#31     IncrementalCompiler.computeDelta (package:front_end/src/fasta/incremental_compiler.dart:113:20)
<asynchronous suspension>                                               
#32     IncrementalCompiler.compile (package:vm/incremental_compiler.dart:50:44)
<asynchronous suspension>                                               
#33     FrontendCompiler.recompileDelta (package:vm/frontend_server.dart:461:26)
<asynchronous suspension>                                               
#34     _FlutterFrontendCompiler.recompileDelta (package:frontend_server/server.dart:36:22)
<asynchronous suspension>                                               
#35     listenAndCompile.<anonymous closure> (package:vm/frontend_server.dart:733:20)
<asynchronous suspension>                                               
#36     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)        
#37     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#38     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#39     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#40     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#41     _StringAdapterSink.add (dart:convert/string_conversion.dart:238:11)
#42     _LineSplitterSink._addLines (dart:convert/line_splitter.dart:150:13)
#43     _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:125:5)
#44     StringConversionSinkMixin.add (dart:convert/string_conversion.dart:165:5)
#45     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#46     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)        
#47     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#48     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#49     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#50     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#51     _StringAdapterSink.add (dart:convert/string_conversion.dart:238:11)
#52     _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:243:7)
#53     _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:314:20)
#54     _Utf8ConversionSink.add (dart:convert/string_conversion.dart:307:5)
#55     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:74:18)
#56     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#57     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)        
#58     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#59     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#60     _SyncStreamController._sendData (dart:async/stream_controller.dart:764:19)
#61     _StreamController._add (dart:async/stream_controller.dart:640:7)
#62     _StreamController.add (dart:async/stream_controller.dart:586:5) 
#63     _Socket._onData (dart:io/runtime/binsocket_patch.dart:1774:41)  
#64     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)        
#65     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#66     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#67     _SyncStreamController._sendData (dart:async/stream_controller.dart:764:19)
#68     _StreamController._add (dart:async/stream_controller.dart:640:7)
#69     _StreamController.add (dart:async/stream_controller.dart:586:5) 
#70     new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1323:33)
#71     _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:844:14)
#72     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)       
#73     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)   
#74     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#75     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)

#0      RangeError.checkValueInInterval (dart:core/errors.dart:281:7)   
#1      Source.getLocation (package:kernel/ast.dart:5793:16)            
#2      getLocation (package:front_end/src/fasta/messages.dart:16:52)   
#3      ProcessedOptions.format (package:front_end/src/base/processed_options.dart:192:47)
#4      ProcessedOptions.report (package:front_end/src/base/processed_options.dart:216:43)
#5      CompilerContext.report (package:front_end/src/fasta/compiler_context.dart:68:13)
#6      Loader.addMessage (package:front_end/src/fasta/loader.dart:274:20)
#7      Loader.addProblem (package:front_end/src/fasta/loader.dart:225:12)
#8      LibraryBuilder.addProblem (package:front_end/src/fasta/builder/library_builder.dart:109:19)
#9      KernelLibraryBuilder.addProblem (package:front_end/src/fasta/kernel/kernel_library_builder.dart:250:47)
#10     KernelLibraryBuilder.reportTypeArgumentIssue (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1512:5)
#11     KernelLibraryBuilder.reportTypeArgumentIssues (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1497:7)
#12     KernelLibraryBuilder.checkBoundsInType (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1620:7)
#13     KernelLibraryBuilder.checkBoundsInField (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1517:5)
#14     KernelClassBuilder.checkBoundsInOutline (package:front_end/src/fasta/kernel/kernel_class_builder.dart:387:15)
#15     KernelLibraryBuilder.checkBoundsInOutline (package:front_end/src/fasta/kernel/kernel_library_builder.dart:1753:21)
#16     SourceLoader.checkBounds.<anonymous closure> (package:front_end/src/fasta/source/source_loader.dart:854:16)
#17     __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:367:8)
#18     SourceLoader.checkBounds (package:front_end/src/fasta/source/source_loader.dart:850:14)
#19     KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:265:14)
<asynchronous suspension>                                               
#20     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>                                               
#21     KernelTarget.buildOutlines (package:front_end/src/fasta/kernel/kernel_target.dart:238:12)
<asynchronous suspension>                                               
#22     IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:254:22)
<asynchronous suspension>                                               
#23     CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:46)
#24     new Future.sync (dart:async/future.dart:224:31)                 
#25     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:19)
#26     _rootRun (dart:async/zone.dart:1124:13)                         
#27     _CustomZone.run (dart:async/zone.dart:1021:19)                  
#28     _runZoned (dart:async/zone.dart:1516:10)                        
#29     runZoned (dart:async/zone.dart:1463:12)                         
#30     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#31     IncrementalCompiler.computeDelta (package:front_end/src/fasta/incremental_compiler.dart:113:20)
<asynchronous suspension>                                               
#32     IncrementalCompiler.compile (package:vm/incremental_compiler.dart:50:44)
<asynchronous suspension>                                               
#33     FrontendCompiler.recompileDelta (package:vm/frontend_server.dart:461:26)
<asynchronous suspension>                                               
#34     _FlutterFrontendCompiler.recompileDelta (package:frontend_server/server.dart:36:22)
<asynchronous suspension>                                               
#35     listenAndCompile.<anonymous closure> (package:vm/frontend_server.dart:733:20)
<asynchronous suspension>                                               
#36     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)        
#37     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#38     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#39     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#40     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#41     _StringAdapterSink.add (dart:convert/string_conversion.dart:238:11)
#42     _LineSplitterSink._addLines (dart:convert/line_splitter.dart:150:13)
#43     _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:125:5)
#44     StringConversionSinkMixin.add (dart:convert/string_conversion.dart:165:5)
#45     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#46     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)        
#47     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#48     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#49     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#50     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#51     _StringAdapterSink.add (dart:convert/string_conversion.dart:238:11)
#52     _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:243:7)
#53     _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:314:20)
#54     _Utf8ConversionSink.add (dart:convert/string_conversion.dart:307:5)
#55     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:74:18)
#56     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#57     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)        
#58     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#59     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#60     _SyncStreamController._sendData (dart:async/stream_controller.dart:764:19)
#61     _StreamController._add (dart:async/stream_controller.dart:640:7)
#62     _StreamController.add (dart:async/stream_controller.dart:586:5) 
#63     _Socket._onData (dart:io/runtime/binsocket_patch.dart:1774:41)  
#64     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)        
#65     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#66     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#67     _SyncStreamController._sendData (dart:async/stream_controller.dart:764:19)
#68     _StreamController._add (dart:async/stream_controller.dart:640:7)
#69     _StreamController.add (dart:async/stream_controller.dart:586:5) 
#70     new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1323:33)
#71     _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:844:14)
#72     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)       
#73     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)   
#74     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#75     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
Performing hot restart...                                              ⣷Unhandled exception:
SocketException: Write failed (OS Error: Broken pipe, errno = 32), port = 0
#0      _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
#1      _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#2      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#3      _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#4      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
dnfield commented 5 years ago

/cc @HansMuller who reported similar

dnfield commented 5 years ago

/cc @aam you have any idea on this one?

aam commented 5 years ago

I believe we don't handle correctly the situation where update failure is caused by analysis step. We currently assume that if app update failed, then it was after compilation was done, so we are telling the compiler to reject the changes. In this case compiler didn't to see the changes, so there is nothing to reject.

HansMuller commented 5 years ago

I also run into this failure mode about once a day. One sign that things have failed and that restarting will no longer recover the app is this sort of compilation error: Foo/1/... can't be assigned to Foo/2/.... For example:

Performing hot restart...
Restarted application in 1,719ms.
I/flutter (11894): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (11894): The following _CompileTimeError was thrown building HomePage(dirty):
I/flutter (11894): 'package:test_issue/main.dart': error: lib/main.dart:15:31: Error: The argument type
I/flutter (11894): 'List/1/<Widget>' can't be assigned to the parameter type 'List/2/<Widget>'.
I/flutter (11894):  - 'List/1/' is from 'dart:core'.
I/flutter (11894):  - 'Widget' is from 'package:flutter/src/widgets/framework.dart'
I/flutter (11894):    ('file:///usr/local/google/home/hansmuller/github/flutter/packages/flutter/lib/src/widgets/framework.dart').
I/flutter (11894):  - 'List/2/' is from 'dart:core'.
I/flutter (11894): Try changing the type of the parameter, or casting the argument to 'List/2/<Widget>'.
I/flutter (11894):             children: <Widget>[
I/flutter (11894):                               ^
aam commented 5 years ago

@HansMuller wrote

I also run into this failure mode about once a day. One sign that things have failed and that restarting will no longer recover the app is this sort of compilation error: Foo/1/... can't be assigned to Foo/2/....

what you see seems to be different, tracked on https://github.com/dart-lang/sdk/issues/35715.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.