knopp / msgpack_dart

MsgPack implementation for dart / msgpack.org[Dart]
MIT License
56 stars 13 forks source link

signal 11 (SIGSEGV), code 2 (SEGV_ACCERR) #15

Closed jasonhe88 closed 11 months ago

jasonhe88 commented 12 months ago

OS: Mac Mini M2 13.4.1 Flutter: 3.10.6 Dart: 3.0.6

error message:

I/flutter ( 6213): {c: 53, i: 686085999305953281, k: 1, posts: [{pi: 159309080203182081, cs: [{cy: text, d: POST 2 BY USER 1 RDX 26752 post id: 159309080203182081 roleid 114900035881079, ns: true, as: false, sf: , io: false, ms: false, mw: 0, ss: [], os: [], tgs: []}], eg: [], ri: 114900035881079, ca: 0, su: 108708692099074, y: , b: , ts: 1658763002, mp: 1658763002799, si: {v: 0, l: 0, s: 0, c: 0, k: 0, q: 0, a: 0, g: 0, p: 0, f: 0}}, {pi: 209114773873303553, cs: [{cy: text, d: POST 0 BY USER 1 RDX 26752 post id: 209114773873303553 roleid 114900035881079, ns: true, as: false, sf: , io: false, ms: false, mw: 0, ss: [], os: [], tgs: []}], eg: [], ri: 114900035881079, ca: 0, su: 108903245611010, y: , b: , ts: 1661731653, mp: 1661731653478, si: {v: 0, l: 0, s: 0, c: 0, k: 0, q: 0, a: 0, g: 0, p: 0, f: 0}}, {pi: 211164734316163073, cs: [{cy: text, d: POST 1 BY USER 1 RDX 26752 post id: 211164734316163073 roleid 114900035881079, ns: true, as: false, sf: , io: false, ms: false, mw: 0, ss: [], os: [], tgs: []}], eg: [], ri: 1149000358
The Flutter DevTools debugger and profiler on sdk gphone64 arm64 is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:62300/4cW5emwSI9c=/
W/Parcel  ( 6213): Expecting binder but got null!
I/m.example.mpack( 6213): Compiler allocated 4579KB to compile void android.view.ViewRootImpl.performTraversals()
F/libc    ( 6213): Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xb400007a86cb9000 in tid 6234 (1.ui), pid 6213 (m.example.mpack)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone64_arm64/emu64a:13/TE1A.220922.031/10278734:userdebug/dev-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2023-07-24 10:12:13.897223890+0800
Process uptime: 3s
Cmdline: com.example.mpack
pid: 6213, tid: 6234, name: 1.ui  >>> com.example.mpack <<<
uid: 10173
tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
pac_enabled_keys: 000000000000000f (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY)
signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xb400007a86cb9000
    x0  00000000fff957e6  x1  0000000000000000  x2  0000000000000000  x3  00000077047dcf85
    x4  b400007a86cb9000  x5  0000000000000000  x6  0000007700847301  x7  000000000000040c
    x8  0000000000000007  x9  00000078ac085c30  x10 b400007a56c5cd80  x11 00000078be736d58
    x12 000000000003d000  x13 0000000000000002  x14 0000000000000002  x15 00000078be736ea8
    x16 00000078be65e000  x17 00000077059e13f1  x18 00000078b4560000  x19 b400007a86c69310
    x20 b400007a56c5cde8  x21 b400007a56c5ce08  x22 0000007700008081  x23 b400007a56c5cf08
    x24 0000007704cd6ec1  x25 00000077047a7974  x26 b400007a86c69310  x27 0000007704cd6ea0
    x28 0000000800000077  x29 00000078be736ec8
    lr  00000078a35309bc  sp  00000078be65d000  pc  00000078a3e95444  pst 00000000a0001000
backtrace:
      #00 pc 0000000000115444  [anon:dart-code]
Lost connection to device.

code:

void test() async {

    ByteData bytes1 = await rootBundle.load('assets/data1');
    var result1 = MPack.deserialize(Uint8List.view(bytes1.buffer));
    print(result1);

    ByteData bytes2 = await rootBundle.load('assets/data2');
    var result2 = MPack.deserialize(Uint8List.view(bytes2.buffer));
    print(result2);

  }

summary:

this crash ONLY happens on combination of following conditions:

  1. Flutter app (pure dart code is ok)
  2. and in Debug mode, profile mode is ok
  3. and in Android emulator, tried android 11, 12, 13, all same, real mobile in debug mode is ok
  4. and unpack two data packs, if only unpack one of them, it's ok
  5. and two data pack are a little bit big, in my case, about 4k, if one of data packs is small, like 2k, will be ok

very interesting .....

jasonhe88 commented 12 months ago

when try to deserialize following data

['k0'=>'', 'k1'=>'', 'k2'=>'', .... 'k999'=>'']

will always get crash

when unpack following array:

['k0'=>'v0', 'k1'=>'v1', 'k2'=>'v2', .... 'k999'=>'v999']

it's ok

after tracing source code, found line 182 @ deserializer.dart trigger the problem.

jasonhe88 commented 12 months ago

tried on intel Mac OS, it's ok

knopp commented 12 months ago

Not much I can do about this - seems like a dart VM problem. Best course of action would be to report this to

https://github.com/dart-lang/sdk/issues

preferably with fully reproducible example.

jasonhe88 commented 12 months ago

Yeah, now i think it may be dart VM problem, thank you for your nice plugin!

jasonhe88 commented 12 months ago

finally I found if i change line 175 in deserializer.dart from

final list = _readBuffer(length);

to

final list = length==0 ? Uint8List(0) : _readBuffer(length);

will resolve the problem !!

knopp commented 11 months ago

The workaround is nice to have, but this still should not crash the VM. This needs to be fixed in dart SDK. Btw. Does this happen in release mode?

jasonhe88 commented 11 months ago

The workaround is nice to have, but this still should not crash the VM. This needs to be fixed in dart SDK. Btw. Does this happen in release mode?

No, it only happens in debug mode in android emulator on apple silicon chip

understood it's dart VM problem, will use this workaround until get fix in dart.