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

object.cc: 16408: error: unreachable code when calling _typeOf<Provider<S>>() #32942

Closed
kgberry83 opened this issue Apr 22, 2018 · 14 comments
Closed
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@kgberry83
Copy link

This code does not fail on startup, but during hot reload.

Flutter version
Flutter 0.3.0 • channel dev • https://github.com/flutter/flutter.git
Framework • revision c73b8a7cf6 (7 days ago) • 2018-04-12 16:17:26 -0700
Engine • revision 8a6e64a8ef
Tools • Dart 2.0.0-dev.47.0.flutter-4126459025

Repro code

//-------------------------------------------------------------------
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  final String title;

  MyApp({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter Redux Demo",
      theme: ThemeData(
        primarySwatch: Colors.red,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class AppState {

}

class Provider<T> {

}

abstract class PageState<W extends StatefulWidget, S> extends State<W> {
  // Workaround to capture generics
  static Type _typeOf<T>() => T;

  void init() {
    final type1 = _typeOf<Provider<AppState>>(); // works
    final type2 = _typeOf<Provider<S>>(); // DOES NOT WORK - object.cc: 16408: error: unreachable code
  }
}

class MyHomePage extends StatefulWidget {
  final String title;
  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends PageState<MyHomePage, AppState> {
  @override
  Widget build(BuildContext context) {
    super.init(); // calls into method that causes failure

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(

        ),
      ),
    );
  }
}

Log Failure:
Initializing hot reload...
E/DartVM ( 3758): ../../third_party/dart/runtime/vm/object.cc: 16408: error: unreachable code
E/DartVM ( 3758): Dumping native stack trace for thread ec6
E/DartVM ( 3758): [0x0000736d9c49df67] Unknown symbol
E/DartVM ( 3758): [0x0000736d9c49df67] Unknown symbol
E/DartVM ( 3758): [0x0000736d9c739786] Unknown symbol
E/DartVM ( 3758): -- End of DumpStackTrace
F/libc ( 3758): Fatal signal 6 (SIGABRT), code -6 in tid 3782 (Thread-2)


Build fingerprint: 'Android/sdk_google_phone_x86_64/generic_x86_64:7.0/NYC/4662066:userdebug/dev-keys'
Revision: '0'
ABI: 'x86_64'
pid: 3758, tid: 3782, name: Thread-2 >>> com.example.helloworld <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
rax 0000000000000000 rbx 0000736d9b5654f8 rcx ffffffffffffffff rdx 0000000000000006
rsi 0000000000000ec6 rdi 0000000000000eae
r8 0000000000000000 r9 000000000000001f r10 0000000000000008 r11 0000000000000202
r12 0000000000000ec6 r13 0000000000000006 r14 0000736d9c7a2837 r15 0000736d9b55dbd0
cs 0000000000000033 ss 000000000000002b
rip 0000736db7c93b67 rbp 0000000000000000 rsp 0000736d9b55da38 eflags 0000000000000202
backtrace:
#00 pc 000000000008db67 /system/lib64/libc.so (tgkill+7)
#1 pc 000000000008a601 /system/lib64/libc.so (pthread_kill+65)
#2 pc 0000000000030241 /system/lib64/libc.so (raise+17)
#3 pc 000000000002877d /system/lib64/libc.so (abort+77)
#4 pc 000000000078c695 /data/app/com.example.helloworld-1/lib/x86_64/libflutter.so
#5 pc 0000000000a8078a /data/app/com.example.helloworld-1/lib/x86_64/libflutter.so
#6 pc 0000000000750ed2 /data/app/com.example.helloworld-1/lib/x86_64/libflutter.so
#7 pc 0000000000704cf6 /data/app/com.example.helloworld-1/lib/x86_64/libflutter.so
#8 pc 000000000071e48f /data/app/com.example.helloworld-1/lib/x86_64/libflutter.so
#9 pc 000000000082ea2c /data/app/com.example.helloworld-1/lib/x86_64/libflutter.so
#10 pc 000000000000063a anonymous:0000736d98940000
#11 pc 0000000000020fa0 anonymous:0000736d8f580000
#12 pc 0000000000020840 anonymous:0000736d8f580000
#13 pc 0000000000002233 anonymous:0000736d8de00000
#14 pc 0000000000008523 anonymous:0000736d8e100000
#15 pc 000000000000768c anonymous:0000736d8e100000
#16 pc 0000000000006f98 anonymous:0000736d8e100000
#17 pc 000000000003f2c6 anonymous:0000736d8e100000
#18 pc 000000000000687f anonymous:0000736d8e100000
#19 pc 00000000000054b2 anonymous:0000736d8e100000
#20 pc 00000000000046af anonymous:0000736d8e100000
#21 pc 000000000000887b anonymous:0000736d8e100000
#22 pc 000000000000768c anonymous:0000736d8e100000
#23 pc 0000000000006f98 anonymous:0000736d8e100000
#24 pc 000000000000687f anonymous:0000736d8e100000
#25 pc 00000000000054b2 anonymous:0000736d8e100000
#26 pc 00000000000046af anonymous:0000736d8e100000
#27 pc 0000000000031077 anonymous:0000736d8db80000
#28 pc 00000000000054b2 anonymous:0000736d8e100000
#29 pc 00000000000046af anonymous:0000736d8e100000
#30 pc 0000000000031077 anonymous:0000736d8db80000
#31 pc 00000000000054b2 anonymous:0000736d8e100000
#32 pc 00000000000046af anonymous:0000736d8e100000
#33 pc 0000000000031077 anonymous:0000736d8db80000
#34 pc 00000000000054b2 anonymous:0000736d8e100000
#35 pc 00000000000046af anonymous:0000736d8e100000
#36 pc 0000000000031077 anonymous:0000736d8db80000
#37 pc 00000000000054b2 anonymous:0000736d8e100000
#38 pc 00000000000046af anonymous:0000736d8e100000
#39 pc 000000000000887b anonymous:0000736d8e100000
#40 pc 000000000000768c anonymous:0000736d8e100000
#41 pc 0000000000006f98 anonymous:0000736d8e100000
#42 pc 000000000003f2c6 anonymous:0000736d8e100000
#43 pc 000000000000687f anonymous:0000736d8e100000
#44 pc 00000000000054b2 anonymous:0000736d8e100000
#45 pc 00000000000046af anonymous:0000736d8e100000
#46 pc 000000000000887b anonymous:0000736d8e100000
#47 pc 000000000000768c anonymous:0000736d8e100000
#48 pc 0000000000006f98 anonymous:0000736d8e100000
#49 pc 000000000000687f anonymous:0000736d8e100000
#50 pc 00000000000054b2 anonymous:0000736d8e100000
#51 pc 00000000000046af anonymous:0000736d8e100000
#52 pc 000000000000887b anonymous:0000736d8e100000
#53 pc 000000000000768c anonymous:0000736d8e100000
#54 pc 0000000000006f98 anonymous:0000736d8e100000
#55 pc 000000000003f2c6 anonymous:0000736d8e100000
#56 pc 000000000000687f anonymous:0000736d8e100000
#57 pc 00000000000054b2 anonymous:0000736d8e100000
#58 pc 00000000000046af anonymous:0000736d8e100000
#59 pc 0000000000031077 anonymous:0000736d8db80000
#60 pc 00000000000054b2 anonymous:0000736d8e100000
#61 pc 00000000000046af anonymous:0000736d8e100000
#62 pc 000000000000887b anonymous:0000736d8e100000
#63 pc 000000000000768c anonymous:0000736d8e100000
Lost connection to device.

@dgrove dgrove added this to the Dart2Beta4 milestone Apr 22, 2018
@dgrove dgrove added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Apr 22, 2018
@dgrove
Copy link
Contributor

dgrove commented Apr 22, 2018

Tentatively targeting beta4

@dgrove dgrove added the crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. label Apr 22, 2018
@a-siva a-siva assigned aam and unassigned a-siva May 3, 2018
@a-siva a-siva added the P1 A high priority bug; for example, a single project is unusable or has many test failures label May 3, 2018
@aam
Copy link
Contributor

aam commented May 7, 2018

I am not able to reproduce this right away - hot reload seems to be working fine as I am making changes to 'Flutter Redux Demo' and 'Flutter Demo Home Page' string literals in the code sample above.

 $FH/flutter/bin/flutter doctor
[✓] Flutter (Channel master, v0.3.6-pre.113, on Linux, locale en_US.UTF-8)
    • Flutter version 0.3.6-pre.113 at $FH/flutter
    • Framework revision d820e5f3b1 (4 days ago), 2018-05-03 22:27:29 -0700
    • Engine revision e976be13c5
    • Dart version 2.0.0-dev.53.0.flutter-e6d7d67f4b

@affinnen can you share more details what you change when the hot reload fails for you?

@kgberry83
Copy link
Author

kgberry83 commented May 7, 2018 via email

@aam
Copy link
Contributor

aam commented May 7, 2018

Hot reloading while changing primarySwatch: Colors.red to primarySwatch: Colors.blue also works.
What device did you run this on? I'm running on Android Nexus4, with flutter dev running on Linux host.

@kgberry83
Copy link
Author

kgberry83 commented May 8, 2018

@aam, here are the exact repro steps.

  1. Start Simulator iPhone 6 - 11.2
  2. Create a new app from Visual Studio Code - hello_world
  3. Start Debugging (you may have to set your debug configuration)
  4. Finally, paste the code example I provided above and Save.
  5. Hot reload should trigger and you will get the exception.

Visual Studio Code: Version 1.22.2
Mac OS: 10.13.4
Flutter 0.3.5 • channel dev • https://github.com/flutter/flutter.git
Framework • revision 7ffcd3d22d (13 days ago) • 2018-04-24 14:03:41 -0700
Engine • revision ec611470b5
Tools • Dart 2.0.0-dev.48.0.flutter-fe606f890b

../../third_party/dart/runtime/vm/object.cc: 16463: error: unreachable code
Dumping native stack trace for thread 5507
[0x000000010b18cc67] dart::Profiler::DumpStackTrace(bool)
[0x000000010b18cc67] dart::Profiler::DumpStackTrace(bool)
[0x000000010b44d6e0] dart::DynamicAssertionHelper::Fail(char const*, ...)
[0x000000010b0f6b64] dart::AbstractType::Canonicalize(dart::ZoneGrowableHandlePtrArray<dart::AbstractType const>*) const
[0x000000010b0a86fa] dart::TypeArguments::Canonicalize(dart::ZoneGrowableHandlePtrArray<dart::AbstractType const>*) const
[0x000000010b0fb6f0] dart::Type::Canonicalize(dart::ZoneGrowableHandlePtrArray<dart::AbstractType const>*) const
[0x000000010b0a86fa] dart::TypeArguments::Canonicalize(dart::ZoneGrowableHandlePtrArray<dart::AbstractType const>*) const
[0x000000010b0c2136] dart::TypeArguments::InstantiateAndCanonicalizeFrom(dart::TypeArguments const&, dart::TypeArguments const&, dart::Error*) const
[0x000000010b1dfdc0] dart::DRT_InstantiateTypeArguments(dart::NativeArguments)
[0x000000011e84063b] [Stub] CallToRuntime
[0x000000012557985c] PageState.init
[0x00000001255795f8] _MyHomePageState.build
[0x0000000124cf04b4] StatefulElement.build
[0x0000000124ab7e64] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125542369] StatefulElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000125544e65] SingleChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125544b57] StatelessElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000125544e65] SingleChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000125544e65] SingleChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x000000012555513b] RenderObjectElement.updateChildren
[0x0000000125552bdc] MultiChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125542369] StatefulElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000125544e65] SingleChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125542369] StatefulElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000125544e65] SingleChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125542369] StatefulElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000125544e65] SingleChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125542369] StatefulElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125544b57] StatelessElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125542369] StatefulElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000125544e65] SingleChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125540468] ProxyElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000125544e65] SingleChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125542369] StatefulElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125544b57] StatelessElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000125544e65] SingleChildRenderObjectElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000125540468] ProxyElement.update
[0x0000000124ab3ce5] Element.updateChild
[0x0000000124ab81bc] ComponentElement.performRebuild
[0x0000000124ab700d] Element.rebuild
[0x0000000124aaa7dc] BuildOwner.buildScope
[0x0000000125ae7db6] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame
[0x000000012539dd45] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback
[0x000000012539e4df] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback
[0x00000001211a6955] _Closure.call
[0x0000000125ae7596] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback
[0x0000000125ae6708] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame
[0x00000001253ac12b] _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
[0x0000000121180772] _Closure.call
[0x0000000125ae3bea] Timer._createTimer.<anonymous closure>
[0x00000001211a6955] _Closure.call
[0x0000000125ae2cf5] _Timer._runTimers
[0x0000000125ae0f6f] _Timer._handleMessage
[0x0000000125ae0a7b] _Timer._handleMessage
[0x00000001211a6955] _Closure.call
[0x00000001211a685c] _RawReceivePortImpl._handleMessage
[0x000000011e840a83] [Stub] InvokeDartCode
[0x000000010b03df66] dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&, unsigned long)
[0x000000010b04167e] dart::DartLibraryCalls::HandleMessage(dart::Object const&, dart::Instance const&)
[0x000000010b06c4bd] dart::IsolateMessageHandler::HandleMessage(dart::Message*)
[0x000000010b09590e] dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)
[0x000000010b095a10] dart::MessageHandler::HandleNextMessage()
[0x000000010b38669d] Dart_HandleMessage
[0x000000010aec6509] tonic::DartMessageHandler::OnHandleMessage(tonic::DartState*)
[0x000000010ab0fdd6] fml::MessageLoopImpl::RunExpiredTasks()
[0x000000010ab12abc] fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*)
[0x000000010a521174] __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
[0x000000010a520e32] __CFRunLoopDoTimer
[0x000000010a5209ea] __CFRunLoopDoTimers
[0x000000010a518404] __CFRunLoopRun
[0x000000010a517889] CFRunLoopRunSpecific
[0x000000010ab12c0d] fml::MessageLoopDarwin::Run()
[0x000000010ab0ff0d] fml::MessageLoopImpl::DoRun()
[0x000000010ab12612] std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, fml::Thread::Thread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0> >(void*, void*)
[0x00000001122aa661] _pthread_body
[0x00000001122aa50d] _pthread_body
[0x00000001122a9bf9] thread_start
-- End of DumpStackTrace
Lost connection to device.
Exited (sigterm)

@a-siva
Copy link
Contributor

a-siva commented May 8, 2018

/cc @crelier

@aam
Copy link
Contributor

aam commented May 8, 2018

Can't repro this on iOS simulator on mac neither.
Can you try flutter master channel?
Can you try running your app from command line(flutter run -v, then 'r' to hot reload)?

@aam
Copy link
Contributor

aam commented May 8, 2018

@affinnen wrote:

  1. Create a new app from Visual Studio Code - hello_world
  2. Start Debugging (you may have to set your debug configuration)
  3. Finally, paste the code example I provided above and Save.

Can you please clarify whether it crashes for you only when you replace complete hello_world app with your sample and do hot reload, while hot reload works fine if you start from your sample and hot reload incremental change(like changing primarySwatch color)

@aam
Copy link
Contributor

aam commented May 8, 2018

Here is the stacktrace with line numbers

E/DartVM  (27829): ../../third_party/dart/runtime/vm/object.cc: 16493: error: unreachable code
E/DartVM  (27829): Dumping native stack trace for thread 6cce
E/DartVM  (27829):   [0xa3af498d] Unknown symbol
E/DartVM  (27829):   [0xa3af498d] Unknown symbol
E/DartVM  (27829):   [0xa3db4341] Unknown symbol
E/DartVM  (27829):   [0xa3a850e5] Unknown symbol
E/DartVM  (27829):   [0xa3a41835] Unknown symbol
E/DartVM  (27829):   [0xa3a89271] Unknown symbol
E/DartVM  (27829):   [0xa3a41835] Unknown symbol
E/DartVM  (27829):   [0xa3a574c3] Unknown symbol
E/DartVM  (27829):   [0xa3b32b45] Unknown symbol
E/DartVM  (27829): -- End of DumpStackTrace
F/libc    (27829): Fatal signal 6 (SIGABRT), code -6 in tid 27854 (Thread-579)
I/DEBUG   (  188): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  188): Build fingerprint: 'google/occam/mako:5.1.1/LMP/2348323:userdebug/dev-keys'
I/DEBUG   (  188): Revision: '11'
I/DEBUG   (  188): ABI: 'arm'
I/DEBUG   (  188): pid: 27829, tid: 27854, name: Thread-579  >>> com.yourcompany.sample <<<
I/DEBUG   (  188): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
I/DEBUG   (  188):     r0 00000000  r1 00006cce  r2 00000006  r3 00000000
I/DEBUG   (  188):     r4 afa29dd8  r5 00000006  r6 0000000b  r7 0000010c
I/DEBUG   (  188):     r8 afa27fb8  r9 afa27fb4  sl 00000002  fp 00000000
I/DEBUG   (  188):     ip 00006cce  sp afa277b8  lr b6dbe989  pc b6de3fe4  cpsr 600f0010
I/DEBUG   (  188): 
I/DEBUG   (  188): backtrace:
I/DEBUG   (  188):     #00 pc 0003bfe4  /system/lib/libc.so (tgkill+12)
I/DEBUG   (  188):     #01 pc 00016985  /system/lib/libc.so (pthread_kill+52)
I/DEBUG   (  188):     #02 pc 00017597  /system/lib/libc.so (raise+10)
I/DEBUG   (  188):     #03 pc 00013d3d  /system/lib/libc.so (__libc_android_abort+36)
I/DEBUG   (  188):     #04 pc 000124ec  /system/lib/libc.so (abort+4)
I/DEBUG   (  188):     #05 pc 003e5567  /data/app/com.yourcompany.sample-2/lib/arm/libflutter.so
I/DEBUG   (  188):     #06 pc 01007343  /data/app/com.yourcompany.sample-2/lib/arm/libflutter.so
I/DEBUG   (  188):     #07 pc 00cd80e1  /data/app/com.yourcompany.sample-2/lib/arm/libflutter.so
I/DEBUG   (  188):     #08 pc 00c94833  /data/app/com.yourcompany.sample-2/lib/arm/libflutter.so
I/DEBUG   (  188):     #09 pc 00cdc26d  /data/app/com.yourcompany.sample-2/lib/arm/libflutter.so
I/DEBUG   (  188):     #10 pc 00c94833  /data/app/com.yourcompany.sample-2/lib/arm/libflutter.so
I/DEBUG   (  188):     #11 pc 00caa4bf  /data/app/com.yourcompany.sample-2/lib/arm/libflutter.so
I/DEBUG   (  188):     #12 pc 00d85b41  /data/app/com.yourcompany.sample-2/lib/arm/libflutter.so
I/DEBUG   (  188):     #13 pc 0000031c  <unknown>
I/DEBUG   (  188): 
../../third_party/skia/src/ports/SkMemory_malloc.cpp:41
../../third_party/dart/runtime/platform/assert.cc:43
../../third_party/dart/runtime/vm/object.cc:16493
../../third_party/dart/runtime/vm/object.cc:5425
../../third_party/dart/runtime/vm/object.cc:17809
../../third_party/dart/runtime/vm/object.cc:5425
../../third_party/dart/runtime/vm/object.cc:5301
../../third_party/dart/runtime/vm/runtime_entry.cc:376

@crelier
Copy link
Contributor

crelier commented May 8, 2018

Since we are having trouble reproducing this, I could add some defensive code to prevent this from happening. Hot reload is brittle anyway, so more robust coding cannot hurt. I cannot guarantee it would not crash later, though.

From the stack trace above, I see that a type argument vector is being canonicalized, and a type argument in the vector is null. This can happen for recursive types, when they are not yet finalized. But this should not happen at runtime. This is probably an issue with hot reload, but until we can reproduce it, I do not know why this is happening.

The fix would be to guard these lines in object.cc against a null type argument:

RawTypeArguments* TypeArguments::Canonicalize(TrailPtr trail) const {
  [...]
  if (result.IsNull()) {
    // Canonicalize each type argument.
    AbstractType& type_arg = AbstractType::Handle(zone);
    for (intptr_t i = 0; i < num_types; i++) {
      type_arg = TypeAt(i);
      if (!type_arg.IsNull()) {   // <<<<<< ADD THIS LINE
        type_arg = type_arg.Canonicalize(trail);
        if (IsCanonical()) {
          // Canonicalizing this type_arg canonicalized this type.
          ASSERT(IsRecursive());
          return this->raw();
        }
        SetTypeAt(i, type_arg);
      }  // <<<<<< ADD THIS LINE
    }
  [...]

What do you think?

@aam
Copy link
Contributor

aam commented May 8, 2018

Starting from the app below, then changing three lines marked with //HR will crash VM with the same error.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  final String title;

  MyApp({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter Redux Demo",
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class AppState {

}

class Provider<T> {

}

abstract class PageState<W extends StatefulWidget, S> extends State<W> {
  // Workaround to capture generics
  static Type _typeOf<T>() => T;

  void init() {
    final type1 = _typeOf<Provider<AppState>>(); // works
    final type2 = _typeOf<Provider<S>>(); // DOES NOT WORK - object.cc: 16408: error: unreachable code
  }
}

class MyHomePage extends StatefulWidget {
  final String title;
  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> { //HR: comment this line
//HR class _MyHomePageState extends PageState<MyHomePage, AppState> {
  @override
  Widget build(BuildContext context) {
    //HR super.init(); // calls into method that causes failure

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(

        ),
      ),
    );
  }
}

@crelier
Copy link
Contributor

crelier commented May 8, 2018

Changing the super type of class _MyHomePageState should invalidate all code from this class, including the code for _MyHomePageState.build and its call to super.init().

@aam
Copy link
Contributor

aam commented May 8, 2018

Current theory is that hot-reload request should have been rejected because _MyHomePageState class got different number of type parameters(used to be 1, now it is 2). Since it was not rejected, that leads to the crash further down the pipeline.

cc @rmacnak-google

dart-bot pushed a commit that referenced this issue May 8, 2018
… change.

Bug: #32942
Change-Id: I7f10a327a82ddf23a946b1ba98c63c2e7947d99f
Reviewed-on: https://dart-review.googlesource.com/54313
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
dart-bot pushed a commit that referenced this issue May 9, 2018
There might be better fix with using canonical types for comparison, we
just need to make sure we canonicalize class's type when finalizing it.

Bug:#32942
Change-Id: I2301a7cb91146d587893f91f2d6ee7b731ea3c62
Reviewed-on: https://dart-review.googlesource.com/54314
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
@aam
Copy link
Contributor

aam commented May 9, 2018

Fixed via 2ad715e

@aam aam closed this as completed May 9, 2018
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. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

5 participants