Skip to content

native crash when stopping a background view #45578

@ened

Description

@ened

The following crash happens in my app:

 Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x50 in tid 19451 (Thread-22), pid 19350 (com.company.app)
 #00 pc 000000000062d6e0  /data/app/com.company.app-xxEJixvHwQkcGAKOLTSxdA==/lib/arm64/libflutter.so!libflutter.so (offset 0x270000) (BuildId: 1dcabb1b4291b34e)
 #01 pc 00000000006a26ec  /data/app/com.company.app-xxEJixvHwQkcGAKOLTSxdA==/lib/arm64/libflutter.so!libflutter.so (offset 0x270000) (BuildId: 1dcabb1b4291b34e)
 #02 pc 00000000004c66f4  /data/app/com.company.app-xxEJixvHwQkcGAKOLTSxdA==/lib/arm64/libflutter.so!libflutter.so (offset 0x270000) (BuildId: 1dcabb1b4291b34e)
 #03 pc 0000000000290000  /data/app/com.company.app-xxEJixvHwQkcGAKOLTSxdA==/lib/arm64/libflutter.so!libflutter.so (offset 0x270000) (BuildId: 1dcabb1b4291b34e)
 #04 pc 00000000002926ec  /data/app/com.company.app-xxEJixvHwQkcGAKOLTSxdA==/lib/arm64/libflutter.so!libflutter.so (offset 0x270000) (BuildId: 1dcabb1b4291b34e)
 #05 pc 000000000001800c  /system/lib64/libutils.so (android::Looper::pollInner(int)+860) (BuildId: 1a9baf080e66cccc6106194a0c4147f8)
 #06 pc 0000000000017c10  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+56) (BuildId: 1a9baf080e66cccc6106194a0c4147f8)
 #07 pc 0000000000013730  /system/lib64/libandroid.so (ALooper_pollOnce+96) (BuildId: 87358a2213d3f3ed7ef4a58f7912a524)
 #08 pc 0000000000292808  /data/app/com.company.app-xxEJixvHwQkcGAKOLTSxdA==/lib/arm64/libflutter.so!libflutter.so (offset 0x270000) (BuildId: 1dcabb1b4291b34e)
 #09 pc 000000000028f1d8  /data/app/com.company.app-xxEJixvHwQkcGAKOLTSxdA==/lib/arm64/libflutter.so!libflutter.so (offset 0x270000) (BuildId: 1dcabb1b4291b34e)
 #10 pc 0000000000291290  /data/app/com.company.app-xxEJixvHwQkcGAKOLTSxdA==/lib/arm64/libflutter.so!libflutter.so (offset 0x270000) (BuildId: 1dcabb1b4291b34e)
 #11 pc 00000000000e2364  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: b58d049709674405423a8d8de1a37f56)
 #12 pc 0000000000083d98  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: b58d049709674405423a8d8de1a37f56)

It can be consistently triggered by the following Kotlin code:

    fun stopAlarmService() {
        sBackgroundFlutterView?.destroy()
        sBackgroundFlutterView?.pluginRegistry?.onViewDestroy(sBackgroundFlutterView)

        sBackgroundFlutterView = null

        sIsIsolateCreated.set(false)
        sIsIsolateInitialized.set(false)
        sIsIsolatePaused.set(true)
    }

The isolate lives in a standard android Service object (it's created during onCreate, and kept in a static variable, but will be stopped once the service ends).

The isolate may spawn child isolates.

The isolate will load plugins, and they themselves may spawn isolates or connect to the background services.

The issue does look like a native crash though, perhaps some housekeeping / pointers are incorrect?

%  flutter doctor -v
[✓] Flutter (Channel dev, v1.12.11, on Mac OS X 10.15.1 19B88, locale en-US)
    • Flutter version 1.12.11 at /Users/ened/dev/flutter
    • Framework revision f40dbf8ca0 (3 days ago), 2019-11-23 01:02:54 -0500
    • Engine revision d1cac77d5a
    • Dart version 2.7.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /usr/local/share/android-sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /usr/local/share/android-sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.2, Build version 11B52
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.39.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.6.0

[✓] Connected device (1 available)
    • Pixel 2 • HT83G1A03545 • android-arm64 • Android 10 (API 29)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowdependency: androidAndroid team may need to help usengineflutter/engine related. See also e: labels.platform-androidAndroid applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions