groue / GRDB.swift

A toolkit for SQLite databases, with a focus on application development
MIT License
6.72k stars 694 forks source link

Crash on iOS 9 & 10, but I don't see any useful infos in my symbolicated crashlogs #870

Closed georgbachmann closed 3 years ago

georgbachmann commented 3 years ago

I am using GRDB via SwiftPackageManager and it seems as if I missed on how to get Xcode to properly generate dsym files for GRDB. Anyway... since I am using GRDB, I am seeing some crashes and they only seem to affect older devices running iOS 9 & 10. The crash seems to happen in DatabaseQueue.init.

All I can see are logs that look like the following:

Thread 0 name:
Thread 0 Crashed:
0   libswiftCore.dylib              0x018abef0 0x17b0000 + 1031920
1   libswiftCore.dylib              0x019a79a2 0x17b0000 + 2062754
2   MyAwesomeApp                    0x00ea8f84 _hidden#1297_ + 62 (__hidden#523_:0)
3   MyAwesomeApp                    0x00ec6f5e _hidden#3781_ + 596 (__hidden#523_:0)
4   MyAwesomeApp                    0x00ebb4c2 _hidden#3779_ + 126
5   MyAwesomeApp                    0x00eb777e 0xe44000 + 472958
6   MyAwesomeApp                    0x00eb73ce 0xe44000 + 472014 (__hidden#4022_:215)
7   MyAwesomeApp                    0x00efdfc4 _hidden#9443_ + 18 (__hidden#9466_:53)
8   MyAwesomeApp                    0x00ec21ec _hidden#4856_ + 12 (__hidden#523_:0)
9   MyAwesomeApp                    0x00efdff2 _hidden#4958_ + 16 (__hidden#523_:0)
10  libswiftDispatch.dylib          0x01bd2cf4 0x1bc0000 + 77044
11  libswiftDispatch.dylib          0x01bcd88e 0x1bc0000 + 55438
12  libswiftDispatch.dylib          0x01bd2d4e 0x1bc0000 + 77134
13  libswiftDispatch.dylib          0x01bd2bd4 0x1bc0000 + 76756
14  libswiftDispatch.dylib          0x01bc8c88 0x1bc0000 + 35976
15  libdispatch.dylib               0x1aff5a34 _dispatch_barrier_sync_f_invoke + 50 (queue.c:3446)
16  libswiftDispatch.dylib          0x01bcdd32 0x1bc0000 + 56626
17  libswiftDispatch.dylib          0x01bd10ac 0x1bc0000 + 69804
18  libswiftDispatch.dylib          0x01bcd778 0x1bc0000 + 55160
19  libswiftDispatch.dylib          0x01bcdca0 0x1bc0000 + 56480
20  MyAwesomeApp                    0x00efdf44 0xe44000 + 761668 (__hidden#9466_:51)
21  MyAwesomeApp                    0x00eca252 0xe44000 + 549458
22  MyAwesomeApp                    0x00ec9006 DatabaseQueue.init(path:configuration:) + 16 (__hidden#523_:0)
23  MyAwesomeApp                    0x00e4976c init + 34 (<compiler-generated>:0)

I know it's super hard for anybody to get any clue on what that could be. But maybe somebody has any idea on how I could get the whole thing to symbolicate properly (It's only readable until line 22 -> DatabaseQueue.init)? I don't have a devices that old to play with and reproduce it myself. But it seems to affect every old device all the time...

groue commented 3 years ago

Hello @georgbachmann. Remember to provide all the information that was requested when you opened this issue (see https://github.com/groue/GRDB.swift/issues/new). This may help someone telling you how to symbolicate crash logs. Also please provide the crash message(s). It can also ring a bell to someone.

georgbachmann commented 3 years ago

Oh... sorry... of course... forgot about that

Crash reason is: EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000000000000005c

GRDB flavor(s): GRDB GRDB version: 4.14.0 Installation method: SPM Xcode version: Xcode 12.1 Swift version: 5.3 Platform(s) running GRDB: iOS macOS version running Xcode: macOS Catalina 10.15. 7

I might have a hint, that in my prepareDatabase statement I had a boolean column that I initialized with a default of "FALSE" which seems to work on newer iOS devices, but older iOS9&10?!? didn't like that ... not sure if that is the cause of my problem, but it might be...

groue commented 3 years ago

Hmmm. I wonder if FALSE is a literal that was accepted in older SQLite versions. Check with a simulator. Use 0 (zero) instead if you witness any error.

georgbachmann commented 3 years ago

Yes, I think it didn't. Seems to work fine with iOS 11 and above (at least I don't have crashes on those devices...) Still having to fight a bit with the latest xcode to compile onto my super old iPad2 Test-Device to know for sure if this was the problem.

georgbachmann commented 3 years ago

Ok... at least locally that doesn't make any change... no crash no matter if it's TRUE or 1, or FALSE or 0... @groue do you maybe have any other idea what might cause that issue? Do you know any other sqlite specific differences those oder iOS 9 & 10 versions might have? Or might it be some kind of slicing? Cause I need to explicitly add armv7 to my build architectures in order to be able to run on my test iPad...

It's also strange that my crashlogs say HIDDEN... any idea why that might be?

I'd love to upgrade the minimum version of my app to something like 11 or 12... but before I'd love to leave all others with a functioning app...

groue commented 3 years ago

It's difficult to say. You can compare the SQLite versions your app has to support with the release notes:

I can say that GRDB does not generate SQL that is known to create problems with old SQLite versions. GRDB 4.14 claims to support iOS 9.0+. Actually, Xcode has long removed any way to run tests against iOS 9, but GRDB 4.14 was tested with Xcode 10.3 and iOS 10.3.1.

Of course, SQL run by apps themselves can not be controlled by GRDB. Take the FALSE literal, for example, that lives in your app code: it was introduced in SQLite 3.23.0: http://sqlite.org/releaselog/3_23_0.html and iOS... 12.

georgbachmann commented 3 years ago

Thanks for your help @groue and for the links! Quite useful! About the HIDDEN inside my crashlogs. Do you have any idea on those? Maybe those would bring me further...

groue commented 3 years ago

It's also strange that my crashlogs say HIDDEN... any idea why that might be?

Nope. Solving this dsym issue looks like a priority - it could help solving this issue, but other crashes as well. Remember to tell the crash message as well. A stack trace rarely comes back alone.

georgbachmann commented 3 years ago

Ah... shit... forgot that :) It's EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000000000000005c I'll update my reply up there as well

georgbachmann commented 3 years ago

And maybe one more question @groue if I may... I have one of the devices here that are crashing according to my logs. 100% of the time... But when I compile the app with Xcode onto the device, it's not happening. Also not in release mode. And also not when launching it then without debugger... Do you maybe have any idea on why that might be the case?

groue commented 3 years ago

No! Focus on your dsyms so that you have as much information as possible when you try to solve those crashes!

georgbachmann commented 3 years ago

But there's no setting to somehow get those SPM dsyms as well, right? I just also don't know why they aren't included... Anyway... thanks for your help and I'll keep you posted once I got to the bottom of this!

georgbachmann commented 3 years ago

Bonjour @groue. I guess I "found" the problem. It was Apples Bitcoding. I now turned that off, and with no other change it's now working like it should... So i guess we can close this issue! Thanks for your fast help though 👍

tamc commented 3 years ago

Just in case someone else is reading this issue, I hit the same as @georgbachmann and the same solution worked. The GDRB database opening would cause a crash on iOS 9, when the app installed via TestFlight, but not if the app is installed directly. Switching the Enable Bitcode build option to No resolved the problem.