flutter-tizen / engine

The Flutter engine
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
6 stars 19 forks source link

Flutter 2.8 crashes with SIGSEGV in release mode #219

Closed swift-kim closed 2 years ago

swift-kim commented 2 years ago

A segmentation fault occurs only in release mode:

* thread #25, name = 'io.flutter.ui', stop reason = signal SIGSEGV: invalid address (fault address: 0x8)
  * frame #0: 0xe16a43e4
    frame #1: 0xe16bc050
    frame #2: 0xe17001d4
    frame #3: 0xe16ff3c0
    frame #4: 0xe16ff250
    frame #5: 0xe16ff03c
    frame #6: 0xe16fef10
    frame #7: 0xe1770adc
    frame #8: 0xe17709e0
    frame #9: 0xe17709b8
    frame #10: 0xe183b1a0
    frame #11: 0xe183b1cc
    frame #12: 0xe183d138
    frame #13: 0xe16c6430
    frame #14: 0xe16765d4
    frame #15: 0xe16766b4
    frame #16: 0xe18180f0
    frame #17: 0xe1677454
    frame #18: 0xe1679058
    frame #19: 0xe16c6264
    frame #20: 0xe183d7f0
    frame #21: 0xe167e288
    frame #22: 0xe183d138
    frame #23: 0xe167c80c
    frame #24: 0xe166eaa4
    frame #25: 0xe3a27216 libflutter_engine.so`dart::DartEntry::InvokeCode(code=<unavailable>, entry_point=<unavailable>, arguments_descriptor=<unavailable>, arguments=<unavailable>, thread=<unavailable>) at dart_entry.cc:0
    frame #26: 0xe183afb4

How to reproduce:

  1. Fetch https://github.com/flutter-tizen/flutter-tizen/pull/287.
  2. Run TIZEN_ENGINE_AZURE_BUILD_ID=699 flutter-tizen precache --tizen.
  3. Run any Flutter app in release mode on any of your devices (arm or arm64).

Not sure how to debug because the crash occurs in the UI thread (Dart code), but maybe we can try reverting the Dart runtime version or running an asan build of the engine.

bbrto21 commented 2 years ago

I tried to build engine using --asan, but I got this error :(

../../third_party/abseil-cpp/absl/base/dynamic_annotations.h:451:10: fatal error: 'sanitizer/common_interface_defs.h' file not found
bwikbs commented 2 years ago

@bbrto21 Are you saying the asan build failed? Is it the same for x64?

bwikbs commented 2 years ago

Plz, Ignore this, I was mistaken because I was not in the office. :cry:

Not sure..., but with this seemed to run on arm64.

diff --git a/tools/gn b/tools/gn
index f10bd92221..87a6e20582 100755
--- a/tools/gn
+++ b/tools/gn
@@ -390,6 +390,9 @@ def to_gn_args(args):
     if args.target_os in ['android'] and gn_args['target_cpu'] in ['x64' , 'arm64']:
       gn_args['dart_use_compressed_pointers'] = True

+    if args.target_os in ['linux'] and gn_args['target_cpu'] in ['x64' , 'arm64']:
+      gn_args['dart_use_compressed_pointers'] = True
+
     return gn_args

 def parse_args(args):
swift-kim commented 2 years ago

I think we are using a wrong gen_snapshot. It seems Android's gen_snapshot artifacts are no longer compatible with Tizen.

bbrto21 commented 2 years ago

I think we are using a wrong gen_snapshot. It seems Android's gen_snapshot artifacts are no longer compatible with Tizen.

Great! How did you figure this out?

swift-kim commented 2 years ago

I knew it because I authored that part of the CI script: https://github.com/flutter-tizen/engine/pull/20/commits/f51d6825979229a9b83757f837e138caa6be7717

bwikbs commented 2 years ago

I have not been understand about gen_snapshot stuff.... So.. Where should we fix it? 👀

swift-kim commented 2 years ago

@bwikbs I think we need to build and release our own gen_snapshots in the engine CI. I'll ask @WonyoungChoi or @bbrto21 to add Windows and macOS jobs to our GitHub Actions worflow. gen_snapshot can be built without having to build the whole engine on Windows: https://github.com/flutter/flutter/wiki/Compiling-the-engine#compiling-for-windows

bwikbs commented 2 years ago

@swift-kim I am still confused... This is Engine CI problem.. In my case, I build it myself.. Why am I going to be a problem? Don't you have a problem if you build it by yourself?

swift-kim commented 2 years ago

You build.. what?

As I told in the above we're currently using Android's gen_snapshot artifacts.

https://github.com/flutter-tizen/flutter-tizen/blob/399090f47bd0e1408bb964fabc33768e14ea051e/lib/tizen_cache.dart#L27

This decision was because we couldn't afford Windows and macOS EC2 instances when we were setting up the Azure Pipelines CI earlier in this year. Only gen_snapshots for Linux x64 are generated if you build the Flutter engine on a Linux machine. To build gen_snapshots for Windows and macOS hosts, you need to set up the engine build environment on Windows and macOS machines. Now that we are using GitHub Actions for our engine CI, we can now build our own gen_snapshots for Windows and macOS on Windows and macOS instances on GitHub Actions.

bwikbs commented 2 years ago

Aha, I understanded now! I thought this was just a matter of related to Engine. Thank you for a detailed explanation!

bbrto21 commented 2 years ago

I think we are using a wrong gen_snapshot. It seems Android's gen_snapshot artifacts are no longer compatible with Tizen.

@swift-kim Have you tested flutter 2.8 with gen_snapshot generated on windows? (I'm trying it myself... it's taking a long time :sweat_smile:)

swift-kim commented 2 years ago

On Windows, gen_snapshot from android-arm-release worked without this issue (I don't know why), but anyway we need to build our own gen_snapshots to make it work for general cases (especially arm64).

I'll close this issue in favor of https://github.com/flutter-tizen/engine/issues/224.