dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.2k stars 1.57k forks source link

crashes : dart::SimpleHashMap::Lookup(void*, unsigned int, bool) (hashmap.cc:22) #47004

Closed Sunyandong-CS closed 3 years ago

Sunyandong-CS commented 3 years ago

crashes on hashmap.cc:22 in Dart SDK, reported on different devices models with iOS 13,14 The crash stack is different but ends always on hashmap.cc SimpleHashMap::Lookup.

flutter doctor: [✓] Flutter (Channel unknown, 2.0.104-0.0.pre.1, on macOS 11.4 20F71 darwin-x64, locale zh-Hans-CN) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 4.2) [✓] VS Code (version 1.59.1) [✓] Connected device (2 available)

crash1.log crash2.log crash3.log crash4.log

mraleph commented 3 years ago

I think these are incorrectly symbolised (or C++ compiler deduplicated some of the code in a way that lost some of the original source location information). These are all UNREACHABLE/assertion failure crashes.

Do you have original raw crashes (raw unsymbolized PCs) and corresponding Flutter engine version information?

Sunyandong-CS commented 3 years ago

@mraleph our team currnently using custom engine version which was based on engine: 05e680e202af9a92461070cb2d9982acad46c83c .
crash3origin.log crash1origin.log

mraleph commented 3 years ago

I would not be able to symbolize your stacktraces myself if you use a custom build of the engine.

What you could try to do is to -1 PCs in frames, e.g. you have a crash which looks like this:

Pthread id: 485155
Thread 38 name:  DartWorker
 Thread 38 Crashed:
0   libsystem_kernel.dylib          0x00000001991a8d88 0x199183000 + 155016
1   libsystem_pthread.dylib         0x00000001990c11e8 0x1990bf000 + 8680
2   libsystem_c.dylib               0x0000000199014934 0x198fa2000 + 469300
3   Flutter                         0x000000010c330338 0x10be6c000 + 4997944
4   Flutter                         0x000000010c420d74 0x10be6c000 + 5983604
5   Flutter                         0x000000010c41a794 0x10be6c000 + 5957524
6   Flutter                         0x000000010c3c9e8c 0x10be6c000 + 5627532
7   Flutter                         0x000000010c41a288 0x10be6c000 + 5956232
8   Flutter                         0x000000010c41a01c 0x10be6c000 + 5955612
9   Flutter                         0x000000010c4106f8 0x10be6c000 + 5916408
10  Flutter                         0x000000010c3c83d4 0x10be6c000 + 5620692
11  libsystem_pthread.dylib         0x00000001990c9d98 0x1990bf000 + 44440

But you should actually try to symbolize using

Pthread id: 485155
Thread 38 name:  DartWorker
 Thread 38 Crashed:
0   libsystem_kernel.dylib          0x00000001991a8d88 0x199183000 + 155016
1   libsystem_pthread.dylib         0x00000001990c11e8 0x1990bf000 + 8680
2   libsystem_c.dylib               0x0000000199014934 0x198fa2000 + 469300
3   Flutter                         0x000000010c330338 0x10be6c000 + 4997943
4   Flutter                         0x000000010c420d74 0x10be6c000 + 5983603
5   Flutter                         0x000000010c41a794 0x10be6c000 + 5957523
6   Flutter                         0x000000010c3c9e8c 0x10be6c000 + 5627531
7   Flutter                         0x000000010c41a288 0x10be6c000 + 5956231
8   Flutter                         0x000000010c41a01c 0x10be6c000 + 5955611
9   Flutter                         0x000000010c4106f8 0x10be6c000 + 5916407
10  Flutter                         0x000000010c3c83d4 0x10be6c000 + 5620691
11  libsystem_pthread.dylib         0x00000001990c9d98 0x1990bf000 + 44440
Sunyandong-CS commented 3 years ago

@mraleph sorry for the late reply。 i got orgin crash log like that: Pthread id: 19426 Thread 13 name: MTFlutterRoute.1.ui Thread 13 Crashed: 0 libsystem_kernel.dylib 0x00000001ba65d84c 0x1ba636000 + 161868 1 libsystem_pthread.dylib 0x00000001d6eba9e8 0x1d6eb0000 + 43496 2 libsystem_c.dylib 0x00000001974748f4 0x197401000 + 473332 3 Flutter 0x000000010b11c2e8 0x10ac58000 + 4997864 4 Flutter 0x000000010b1fc430 0x10ac58000 + 5915696 5 Flutter 0x000000010b20ed60 0x10ac58000 + 5991776 6 Flutter 0x000000010b2039f8 0x10ac58000 + 5945848 7 Flutter 0x000000010b204f48 0x10ac58000 + 5951304 8 Flutter 0x000000010b11348c 0x10ac58000 + 4961420 9 Flutter 0x000000010af89f28 0x10ac58000 + 3350312 10 Flutter 0x000000010af80d98 0x10ac58000 + 3313048 11 Flutter 0x000000010af2d6c4 0x10ac58000 + 2971332 12 Flutter 0x000000010af2f524 0x10ac58000 + 2979108 13 CoreFoundation 0x000000018e7073e0 0x18e66c000 + 635872 14 CoreFoundation 0x000000018e706fe4 0x18e66c000 + 634852 15 CoreFoundation 0x000000018e7064c4 0x18e66c000 + 632004 16 CoreFoundation 0x000000018e700850 0x18e66c000 + 608336 17 CoreFoundation 0x000000018e6ffba0 0x18e66c000 + 605088 18 Flutter 0x000000010af2f400 0x10ac58000 + 2978816 19 Flutter 0x000000010af2ee04 0x10ac58000 + 2977284 20 libsystem_pthread.dylib 0x00000001d6eb9b3c 0x1d6eb0000 + 39740

and i try to symbolize usingwith -1 PCs in frames,got:

image

it seems the initial symbolization is correct .

Sunyandong-CS commented 3 years ago

@mraleph I sent you an email(me@mrale.ph) with a dsym file and crash log。maybe it can help locate the problem

mraleph commented 3 years ago

Thanks for the dSYM. The trick is to -1 return addresses on the stack to get a correct symbolization. Compare this (using normal addresses from the crash report):

$ atos -o Flutter.dSYM/Contents/Resources/DWARF/Flutter -arch arm64 -l 0x10ac58000 0x000000010b11c2e8 0x000000010b1fc430 0x000000010b20ed60 0x000000010b2039f8 0x000000010b204f48
dart::SimpleHashMap::Lookup(void*, unsigned int, bool) (in Flutter) (hashmap.cc:22)
dart::ThreadPool::RunImpl(std::__1::unique_ptr<dart::ThreadPool::Task, std::__1::default_delete<dart::ThreadPool::Task> >) (in Flutter) (thread_pool.cc:91)
dart::Scavenger::Scavenge() (in Flutter) (scavenger.cc:1499)
dart::Heap::CollectNewSpaceGarbage(dart::Thread*, dart::Heap::GCReason) (in Flutter) (heap.cc:471)
dart::Heap::NotifyIdle(long long) (in Flutter) (heap.cc:388)

to this (using adjusted addresses, with -1 adjustment applied)

$ atos -o Flutter.dSYM/Contents/Resources/DWARF/Flutter -arch arm64 -l 0x10ac58000 0x000000010b11c2e7 0x000000010b1fc42f 0x000000010b20ed5f 0x000000010b2039f7 0x000000010b204f47
dart::Assert::Fail(char const*, ...) (in Flutter) (assert.cc:44)
dart::ThreadPool::RunImpl(std::__1::unique_ptr<dart::ThreadPool::Task, std::__1::default_delete<dart::ThreadPool::Task> >) (in Flutter) (thread_pool.cc:94)
dart::Scavenger::Scavenge() (in Flutter) (scavenger.cc:1499)
dart::Heap::CollectNewSpaceGarbage(dart::Thread*, dart::Heap::GCReason) (in Flutter) (heap.cc:470)
dart::Heap::NotifyIdle(long long) (in Flutter) (heap.cc:381)

The second one makes sense. As I have predicted in https://github.com/dart-lang/sdk/issues/47004#issuecomment-906464104 it is an assertion failure.

I think this assertion failure is in this line of code:

void ThreadPool::Worker::StartThread() {
  int result = OSThread::Start("DartWorker", &Worker::Main,
                               reinterpret_cast<uword>(this));
  if (result != 0) {
    FATAL1("Could not start worker thread: result = %d.", result);  // (!) here
  }
}

most likely you are hitting an OOM situation - the application might be using so much memory that you can't even start a thread.

mraleph commented 3 years ago

I will go ahead and close this because like with all OOM situations crash reports don't actually provide enough context for us to debug the issue.

Sunyandong-CS commented 3 years ago

thank for your help ~