eneural-net / async_task

Asynchronous tasks and parallel executors, supporting all Dart platforms (JS/Web, Flutter, VM/Native) through transparent internal implementations with `dart:isolate` or only `dart:async`, easily bringing concepts similar to Thread Pools to Dart, without having to deal with `Isolate` and port/channel complexity.
Apache License 2.0
53 stars 4 forks source link

Crash: null pointer dereference #4

Closed dudizimber closed 1 year ago

dudizimber commented 2 years ago

I'm working on an app that uses many threads to perform operations in parallel. Sometimes it crashes when spawning them. This was when debugging the app in a OnePlus 7 Pro, Android 11.


Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 2.6.0-12.0.pre.379, on Microsoft Windows [Version 10.0.18363.1316], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.5)
[√] Android Studio (version 4.0)
[√] VS Code (version 1.62.1)
[√] Connected device (3 available)

! Doctor found issues in 1 category.

Output logs:

I/flutter (11420): [INFO] Starting AsyncExecutor{ sequential: false, parallelism: 1, maximumWorkers: 1, status: AsyncExecutorStatus.idle, platform: AsyncTaskPlatform{platformType: AsyncTaskPlatformType.isolate, maximumParallelism: 8}, executorThread: _AsyncExecutorMultiThread{ totalThreads: 1, queue: 0 } }
I/flutter (11420): [INFO] Starting _AsyncExecutorMultiThread{ totalThreads: 1, queue: 0 }
I/flutter (11420): [INFO] Spawning Isolate for _IsolateThread#32
I/flutter (11420): [INFO] Starting AsyncExecutor{ sequential: false, parallelism: 1, maximumWorkers: 1, status: AsyncExecutorStatus.idle, platform: AsyncTaskPlatform{platformType: AsyncTaskPlatformType.isolate, maximumParallelism: 8}, executorThread: _AsyncExecutorMultiThread{ totalThreads: 1, queue: 0 } }
I/flutter (11420): [INFO] Starting _AsyncExecutorMultiThread{ totalThreads: 1, queue: 0 }
I/flutter (11420): [INFO] Spawning Isolate for _IsolateThread#33
I/flutter (11420): [INFO] Starting AsyncExecutor{ sequential: false, parallelism: 1, maximumWorkers: 1, status: AsyncExecutorStatus.idle, platform: AsyncTaskPlatform{platformType: AsyncTaskPlatformType.isolate, maximumParallelism: 8}, executorThread: _AsyncExecutorMultiThread{ totalThreads: 1, queue: 0 } }
I/flutter (11420): [INFO] Starting _AsyncExecutorMultiThread{ totalThreads: 1, queue: 0 }
I/flutter (11420): [INFO] Spawning Isolate for _IsolateThread#34
I/flutter (11420): [INFO] Starting AsyncExecutor{ sequential: false, parallelism: 1, maximumWorkers: 1, status: AsyncExecutorStatus.idle, platform: AsyncTaskPlatform{platformType: AsyncTaskPlatformType.isolate, maximumParallelism: 8}, executorThread: _AsyncExecutorMultiThread{ totalThreads: 1, queue: 0 } }
I/flutter (11420): [INFO] Starting _AsyncExecutorMultiThread{ totalThreads: 1, queue: 0 }
I/flutter (11420): [INFO] Spawning Isolate for _IsolateThread#35
F/libc    (11420): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x680 in tid 8647 (DartWorker), pid 11420 (minecraft_cloud)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'OnePlus/OnePlus7Pro/OnePlus7Pro:11/RKQ1.201022.002/2110211503:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2021-11-16 16:46:24+0200
pid: 11420, tid: 8647, name: DartWorker  >>> com.example.my_app <<<
uid: 10613
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x680
Cause: null pointer dereference
    x0  b4000073a8694578  x1  000000768bac0b14  x2  0000007384f31aa8  x3  0000000000000020
    x4  0000000000000010  x5  0000000000000007  x6  000000768f9c7000  x7  0000000003d8f9c6
    x8  0000000000000000  x9  0000000000000001  x10 0000000000000001  x11 0000000000000030
    x12 0000000000000000  x13 0000000000000050  x14 ffffffffffffffb0  x15 b4000074e8726d30
    x16 00000073281bd738  x17 000000768bac181c  x18 0000007304f74000  x19 b400007478699800
    x20 0000000000000000  x21 0000007327dc5ffc  x22 00000073281604f8  x23 b400007458674670
    x24 b4000074586745f8  x25 b4000074586746a8  x26 00000000004c4b40  x27 0000000000000001
    x28 0000007328298000  x29 00000000000003e8
    lr  0000007327e5020c  sp  0000007384f31ab0  pc  0000007327e50214  pst 0000000080000000
backtrace:
      #00 pc 000000000194c214  /data/app/~~VaikyToU5GigP-8EMMP0MQ==/com.example.minecraft_cloud-gTxLdfttzVunJTPgAzayxQ==/lib/arm64/libflutter.so (BuildId: 74dcf7ba2ff1623934141fe7f2915facfec83f3c)
      #01 pc 00000000018d7df4  /data/app/~~VaikyToU5GigP-8EMMP0MQ==/com.example.minecraft_cloud-gTxLdfttzVunJTPgAzayxQ==/lib/arm64/libflutter.so (BuildId: 74dcf7ba2ff1623934141fe7f2915facfec83f3c)
      #02 pc 00000000018da788  /data/app/~~VaikyToU5GigP-8EMMP0MQ==/com.example.minecraft_cloud-gTxLdfttzVunJTPgAzayxQ==/lib/arm64/libflutter.so (BuildId: 74dcf7ba2ff1623934141fe7f2915facfec83f3c)
      #03 pc 0000000001a47c34  /data/app/~~VaikyToU5GigP-8EMMP0MQ==/com.example.minecraft_cloud-gTxLdfttzVunJTPgAzayxQ==/lib/arm64/libflutter.so (BuildId: 74dcf7ba2ff1623934141fe7f2915facfec83f3c)
      #04 pc 0000000001a47e98  /data/app/~~VaikyToU5GigP-8EMMP0MQ==/com.example.minecraft_cloud-gTxLdfttzVunJTPgAzayxQ==/lib/arm64/libflutter.so (BuildId: 74dcf7ba2ff1623934141fe7f2915facfec83f3c)
      #05 pc 00000000019d7a7c  /data/app/~~VaikyToU5GigP-8EMMP0MQ==/com.example.minecraft_cloud-gTxLdfttzVunJTPgAzayxQ==/lib/arm64/libflutter.so (BuildId: 74dcf7ba2ff1623934141fe7f2915facfec83f3c)
      #06 pc 00000000000b0048  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) (BuildId: 07fbaeed7b7a19203975f06be6f1d5ef)
      #07 pc 00000000000503c8  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 07fbaeed7b7a19203975f06be6f1d5ef)
Lost connection to device.
Exited (sigterm)
gmpassos commented 2 years ago

Hi. Can you create a simple Flutter app that can reproduce the bug and put it on GitHub?

With that I can investigate the issue and fix it.

Thanks for the report!

dudizimber commented 2 years ago

Thanks, I'll try. It's a tough one to catch since it doesn't happen always. What the thread actually was doing is discovering folders and files.

gmpassos commented 2 years ago

In a multithreaded software it's hard to have a deterministic bug. Just put in the readme the orientation in how to enforce the bug.