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

Crashs of Precompiled FfiTrampoline on iOS #44488

Open
latteinlove opened this issue Dec 16, 2020 · 1 comment
Open

Crashs of Precompiled FfiTrampoline on iOS #44488

latteinlove opened this issue Dec 16, 2020 · 1 comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. library-ffi

Comments

@latteinlove
Copy link

latteinlove commented Dec 16, 2020

I used ffi to call the C method and it crashed. The crash information is as follows:

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000

Crashed: io.flutter.1.ui
0  algo                           0x10139d9c4 fill_result + 188
1  App                            0x10a0cf7b0 Precompiled____FfiTrampoline_26367 + 752
2  App                            0x10a0cf758 Precompiled____FfiTrampoline_26367 + 664
3  App                            0x10a0cc298 Precompiled_SleepActivityAlgoApi_getActivityData_26348 + 700
4  App                            0x10a0ca6c4 Precompiled_ActivityDataMerge_getActivityAlgorithmData_26338 + 92
5  App                            0x10a0d14fc Precompiled_ActivityDataMerge_processBluetoothDataItem__async_op_26386 + 2572
6  App                            0x109b3e188 Precompiled_____rootRunUnary_4048458_7575 + 112
7  App                            0x109b3e4bc Precompiled_____rootRunUnary_4048458__rootRunUnary_4048458_7576 + 580
8  App                            0x109e961a0 Precompiled__CustomZone_4048458_runUnary_20615 + 204
9  App                            0x109960100 Precompiled__FutureListener_4048458_handleValue_664 + 208
10 App                            0x10a1053d8 Precompiled__Future_4048458__propagateToListeners_4048458_handleValueCallback_26813 + 84
11 App                            0x10995e718 Precompiled__Future_4048458__propagateToListeners_4048458_639 + 1148
12 App                            0x10995f5f4 Precompiled__Future_4048458__completeWithValue_4048458_653 + 124
13 App                            0x109e91e98 Precompiled__AsyncAwaitCompleter_4048458_complete_20526 + 424
14 App                            0x10994526c Precompiled_____completeOnAsyncReturn_4048458_311 + 56
15 App                            0x10a0c8504 Precompiled_QueryAdapter_query__async_op_26318 + 600
16 App                            0x109b3e188 Precompiled_____rootRunUnary_4048458_7575 + 112
17 App                            0x109b3e4bc Precompiled_____rootRunUnary_4048458__rootRunUnary_4048458_7576 + 580
18 App                            0x109e961a0 Precompiled__CustomZone_4048458_runUnary_20615 + 204
19 App                            0x109960100 Precompiled__FutureListener_4048458_handleValue_664 + 208
20 App                            0x10a1053d8 Precompiled__Future_4048458__propagateToListeners_4048458_handleValueCallback_26813 + 84
21 App                            0x10995e718 Precompiled__Future_4048458__propagateToListeners_4048458_639 + 1148
22 App                            0x10995f5f4 Precompiled__Future_4048458__completeWithValue_4048458_653 + 124
23 App                            0x109e91e98 Precompiled__AsyncAwaitCompleter_4048458_complete_20526 + 424
24 App                            0x10994526c Precompiled_____completeOnAsyncReturn_4048458_311 + 56
25 App                            0x10a0f1ef0 Precompiled__SqfliteDatabaseBase_Object_SqfliteDatabaseMixin_1865204050_txnSynchronized__async_op_26631 + 1148
26 App                            0x109b3e188 Precompiled_____rootRunUnary_4048458_7575 + 112
27 App                            0x109b3e4bc Precompiled_____rootRunUnary_4048458__rootRunUnary_4048458_7576 + 580
28 App                            0x109e961a0 Precompiled__CustomZone_4048458_runUnary_20615 + 204
29 App                            0x109960100 Precompiled__FutureListener_4048458_handleValue_664 + 208
30 App                            0x10a1053d8 Precompiled__Future_4048458__propagateToListeners_4048458_handleValueCallback_26813 + 84
31 App                            0x10995e718 Precompiled__Future_4048458__propagateToListeners_4048458_639 + 1148
32 App                            0x10995f5f4 Precompiled__Future_4048458__completeWithValue_4048458_653 + 124
33 App                            0x109e91e98 Precompiled__AsyncAwaitCompleter_4048458_complete_20526 + 424
34 App                            0x10994526c Precompiled_____completeOnAsyncReturn_4048458_311 + 56
35 App                            0x10a095738 Precompiled_BasicLock_synchronized__async_op_25907 + 1380
36 App                            0x109b3e188 Precompiled_____rootRunUnary_4048458_7575 + 112
37 App                            0x109b3e4bc Precompiled_____rootRunUnary_4048458__rootRunUnary_4048458_7576 + 580
38 App                            0x109e961a0 Precompiled__CustomZone_4048458_runUnary_20615 + 204
39 App                            0x109960100 Precompiled__FutureListener_4048458_handleValue_664 + 208
40 App                            0x10a1053d8 Precompiled__Future_4048458__propagateToListeners_4048458_handleValueCallback_26813 + 84
41 App                            0x10995e718 Precompiled__Future_4048458__propagateToListeners_4048458_639 + 1148
42 App                            0x10995f5f4 Precompiled__Future_4048458__completeWithValue_4048458_653 + 124
43 App                            0x109e91e98 Precompiled__AsyncAwaitCompleter_4048458_complete_20526 + 424
44 App                            0x10994526c Precompiled_____completeOnAsyncReturn_4048458_311 + 56
45 App                            0x10a0eb1b0 Precompiled__SqfliteDatabaseBase_Object_SqfliteDatabaseMixin_1865204050_txnRawQuery__anonymous_closure___async_op_26583 + 512
46 App                            0x109b3e188 Precompiled_____rootRunUnary_4048458_7575 + 112
47 App                            0x109b3e4bc Precompiled_____rootRunUnary_4048458__rootRunUnary_4048458_7576 + 580
48 App                            0x109e961a0 Precompiled__CustomZone_4048458_runUnary_20615 + 204
49 App                            0x109960100 Precompiled__FutureListener_4048458_handleValue_664 + 208
50 App                            0x10a1053d8 Precompiled__Future_4048458__propagateToListeners_4048458_handleValueCallback_26813 + 84
51 App                            0x10995e718 Precompiled__Future_4048458__propagateToListeners_4048458_639 + 1148
52 App                            0x10995f5f4 Precompiled__Future_4048458__completeWithValue_4048458_653 + 124
53 App                            0x109e91e98 Precompiled__AsyncAwaitCompleter_4048458_complete_20526 + 424
54 App                            0x10994526c Precompiled_____completeOnAsyncReturn_4048458_311 + 56
55 App                            0x10a0f2108 Precompiled____wrapDatabaseException__async_op_26632 + 388
56 App                            0x109b3e188 Precompiled_____rootRunUnary_4048458_7575 + 112
57 App                            0x109b3e4bc Precompiled_____rootRunUnary_4048458__rootRunUnary_4048458_7576 + 580
58 App                            0x109e961a0 Precompiled__CustomZone_4048458_runUnary_20615 + 204
59 App                            0x109960100 Precompiled__FutureListener_4048458_handleValue_664 + 208
60 App                            0x10a1053d8 Precompiled__Future_4048458__propagateToListeners_4048458_handleValueCallback_26813 + 84
61 App                            0x10995e718 Precompiled__Future_4048458__propagateToListeners_4048458_639 + 1148
62 App                            0x10995f5f4 Precompiled__Future_4048458__completeWithValue_4048458_653 + 124
63 App                            0x109e91e98 Precompiled__AsyncAwaitCompleter_4048458_complete_20526 + 424
64 App                            0x10994526c Precompiled_____completeOnAsyncReturn_4048458_311 + 56
65 App                            0x10a10357c Precompiled_MethodChannel__invokeMethod_967480135__async_op_26792 + 640
66 App                            0x109b3e188 Precompiled_____rootRunUnary_4048458_7575 + 112
67 App                            0x109b3e4bc Precompiled_____rootRunUnary_4048458__rootRunUnary_4048458_7576 + 580
68 App                            0x109e961a0 Precompiled__CustomZone_4048458_runUnary_20615 + 204
69 App                            0x109960100 Precompiled__FutureListener_4048458_handleValue_664 + 208
70 App                            0x10a1053d8 Precompiled__Future_4048458__propagateToListeners_4048458_handleValueCallback_26813 + 84
71 App                            0x10995e718 Precompiled__Future_4048458__propagateToListeners_4048458_639 + 1148
72 App                            0x10995f5f4 Precompiled__Future_4048458__completeWithValue_4048458_653 + 124
73 App                            0x10a1058cc Precompiled__Future_4048458__asyncCompleteWithValue_4048458__anonymous_closure__26815 + 76
74 App                            0x109b3d804 Precompiled_____rootRun_4048458_7564 + 216
75 App                            0x109b3da84 Precompiled_____rootRun_4048458__rootRun_4048458_7565 + 512
76 App                            0x109e93c6c Precompiled__CustomZone_4048458_run_20567 + 192
77 App                            0x109e965e4 Precompiled__CustomZone_4048458_runGuarded_20623 + 52
78 App                            0x10a059574 Precompiled__CustomZone_4048458_bindCallbackGuarded__anonymous_closure__25345 + 76
79 App                            0x109b3df88 Precompiled_____microtaskLoop_4048458_7572 + 120
80 App                            0x109b3f1f8 Precompiled_____startMicrotaskLoop_4048458_7587 + 40
81 App                            0x109b3f2f8 Precompiled_____startMicrotaskLoop_4048458__startMicrotaskLoop_4048458_7588 + 92
82 App                            0x10993123c Precompiled_Stub_InvokeDartCode + 268
83 Flutter                        0x10197818c (缺少)
84 Flutter                        0x101a57848 (缺少)
85 Flutter                        0x1017e2ca4 (缺少)
86 Flutter                        0x101511dd0 (缺少)
87 Flutter                        0x101513880 (缺少)
88 CoreFoundation                 0x194f6c134 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
89 CoreFoundation                 0x194f6be50 __CFRunLoopDoTimer + 880
90 CoreFoundation                 0x194f6b52c __CFRunLoopDoTimers + 276
91 CoreFoundation                 0x194f6653c __CFRunLoopRun + 1640
92 CoreFoundation                 0x194f65ba8 CFRunLoopRunSpecific + 424
93 Flutter                        0x10151375c (缺少)
94 Flutter                        0x101513128 (缺少)
95 libsystem_pthread.dylib        0x194d03d98 _pthread_start + 156
96 libsystem_pthread.dylib        0x194d0774c thread_start + 8

The getActivityData method is called as follows:

static StepSleepModel getActivityData({int stepInterval = StepInfoModel.DEFAULT_STEP_INTERVAL}) {
    Logcat.debug('$tag getActivityData() )');

    processDataAlg(...);

    final stageStepLength = (1440 / stepInterval).round();

    final sleepInfoPointer = allocate<SleepInfoStruct>();
    final stepInfoPointer = allocate<StepInfoStruct>();
    final stageStepListPointer = allocate<StageStepStruct>(count: stageStepLength);
    final activeListPointer = allocate<ActiveItemStruct>(count: 100);
    final fullActiveListPointer = allocate<ActiveItemStruct>(count: 100);
    final mainStageSleepPointer = allocate<StageSleepStruct>(count: 100);
    final allStageSleepPointer = allocate<StageSleepStruct>(count: 100);
    final lengthResultP = getActivityDataAlg(
      ...,
      stageStepLength,
      stepInfoPointer,
      stageStepListPointer,
      activeListPointer,
      fullActiveListPointer,
      sleepInfoPointer,
      mainStageSleepPointer,
      allStageSleepPointer,
    );
    if (lengthResultP == nullptr) {
      ///free pointer
      free(sleepInfoPointer);
      free(stepInfoPointer);
      free(stageStepListPointer);
      free(activeListPointer);
      free(fullActiveListPointer);
      free(mainStageSleepPointer);
      free(allStageSleepPointer);
      return null;
    }
 ...
}

The getActivityDataAlg method is called as follows:

final getActivityDataAlg = dylib
    .lookup<NativeFunction<get_activity_data_func>>('dataProcess_getData')
    .asFunction<GetActivityData>();
@mit-mit mit-mit added the area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. label Dec 17, 2020
@mkustermann mkustermann added crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. library-ffi labels Dec 17, 2020
@dcharkes
Copy link
Contributor

dcharkes commented Jan 5, 2021

@latteinlove could you please provide a minimal reproduction?

What is the signature of get_activity_data_func and GetActivityData?

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, FFI, and the AOT and JIT backends. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. library-ffi
Projects
None yet
Development

No branches or pull requests

4 participants