Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Crash loop with 'database disk image is malformed' exception #7920

Closed
erichoracek opened this issue Feb 1, 2017 · 20 comments
Closed

Crash loop with 'database disk image is malformed' exception #7920

erichoracek opened this issue Feb 1, 2017 · 20 comments
Labels
crash iOS Mapbox Maps SDK for iOS offline

Comments

@erichoracek
Copy link
Contributor

Hi,

We've received this crash report via HockeyApp for Mapbox 3.3.7. This crash has occurred 13 times in a row for a single user over the course of 1 hour. It appears to happen whenever they perform an action that causes an MGLMapView to be initialized.

It would be great if an error like this caused the database to be wiped rather than crashing the host application. This is by far the top crasher for the most recent version of our app now.

Platform: iOS 10.2.1
Mapbox SDK version: 3.3.7

Date/Time:       2017-02-01T14:07:15Z
Launch Time:     2017-02-01T14:07:10Z
OS Version:      iPhone OS 10.2.1 (14D27)
Report Version:  104

Exception Type:  SIGABRT
Exception Codes: #0 at 0x18117b014
Crashed Thread:  25

Application Specific Information:
*** Terminating app due to uncaught exception 'mapbox::sqlite::Exception', reason: 'database disk image is malformed'

Last Exception Backtrace:
0   libc++abi.dylib                      0x0000000180bd366c std::__terminate(void (*)()) + 16
1   libc++abi.dylib                      0x0000000180bd3234 __cxa_rethrow + 140
2   Mapbox                               0x00000001014b4c6c mbgl::OfflineDatabase::ensureSchema() (offline_database.cpp:62)
3   Mapbox                               0x00000001014b48bc mbgl::OfflineDatabase::OfflineDatabase(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long) (offline_database.cpp:24)
4   Mapbox                               0x00000001014a5b00 void mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::run<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>, 0ul, 1ul>(std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>&&, std::__1::integer_sequence<unsigned long, 0ul, 1ul>) (default_file_source.cpp:29)
5   Mapbox                               0x00000001014a5a64 std::__1::__thread_proxy<std::__1::tuple<mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::Thread<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>(mbgl::util::ThreadContext const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&, unsigned long long&&&)::'lambda'()> >(void*, void*) (thread.hpp:110)
6   libsystem_pthread.dylib              0x0000000181241850 _pthread_body + 236
7   libsystem_pthread.dylib              0x0000000181241760 _pthread_start + 280
8   libsystem_pthread.dylib              0x000000018123ed94 thread_start + 0

Thread 0:
0   libsystem_kernel.dylib               0x000000018117ae1c __psynch_cvwait + 8
1   libc++.1.dylib                       0x0000000180b693ec std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 52
2   libc++.1.dylib                       0x0000000180b69e38 std::__1::__assoc_sub_state::__sub_wait(std::__1::unique_lock<std::__1::mutex>&) + 48
3   libc++.1.dylib                       0x0000000180b69d90 std::__1::__assoc_sub_state::copy() + 48
4   libc++.1.dylib                       0x0000000180b6a0ac std::__1::future<void>::get() + 24
5   Mapbox                               0x00000001014a5964 mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::Thread<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>(mbgl::util::ThreadContext const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&, unsigned long long&&&) (thread.hpp:113)
6   Mapbox                               0x00000001014a36dc mbgl::DefaultFileSource::DefaultFileSource(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long) (thread.hpp:92)
7   Mapbox                               0x00000001013a7a74 -[MGLOfflineStorage init] (MGLOfflineStorage.mm:128)
8   Mapbox                               0x00000001013a73e4 __41+[MGLOfflineStorage sharedOfflineStorage]_block_invoke (MGLOfflineStorage.mm:37)
9   libdispatch.dylib                    0x00000001810361bc _dispatch_client_callout + 12
10  libdispatch.dylib                    0x0000000181036fb0 dispatch_once_f + 52
11  Mapbox                               0x00000001013a73b8 +[MGLOfflineStorage sharedOfflineStorage] (once.h:75)
12  Mapbox                               0x0000000101382398 -[MGLMapView commonInit] (MGLMapView.mm:402)
13  Mapbox                               0x0000000101381a14 -[MGLMapView initWithFrame:] (MGLMapView.mm:308)
14  XXXXXXXXX                            0x00000001001ba1ec +[XXXXXXXXX XXXXXXXXX] (XXXXXXXXX)
15  XXXXXXXXX                            0x000000010028a2f8 -[XXXXXXXXX XXXXXXXXX] (XXXXXXXXX)
16  XXXXXXXXX                            0x000000010014c68c -[XXXXXXXXX XXXXXXXXX] (XXXXXXXXX)
17  UIKit                                0x00000001880625bc -[UIViewController loadViewIfRequired] + 180
18  UIKit                                0x00000001880624ec -[UIViewController view] + 24
19  XXXXXXXXX                            0x000000010020ca34 -[XXXXXXXXX XXXXXXXXX] (XXXXXXXXX)
20  UIKit                                0x0000000188062924 -[UIViewController loadViewIfRequired] + 1052
21  UIKit                                0x000000018807a4b4 -[UIViewController __viewWillAppear:] + 128
22  UIKit                                0x00000001882025b4 -[UINavigationController _startCustomTransition:] + 1132
23  UIKit                                0x000000018811ae74 -[UINavigationController _startDeferredTransitionIfNeeded:] + 672
24  UIKit                                0x000000018811aadc -[UINavigationController __viewWillLayoutSubviews] + 60
25  UIKit                                0x000000018811aa40 -[UILayoutContainerView layoutSubviews] + 184
26  UIKit                                0x000000018805fa80 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1192
27  QuartzCore                           0x000000018550d9d8 -[CALayer layoutSublayers] + 144
28  QuartzCore                           0x00000001855024cc CA::Layer::layout_if_needed(CA::Transaction*) + 288
29  QuartzCore                           0x000000018550238c CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 28
30  QuartzCore                           0x000000018547f3e0 CA::Context::commit_transaction(CA::Transaction*) + 248
31  QuartzCore                           0x00000001854a6a68 CA::Transaction::commit() + 508
32  QuartzCore                           0x00000001854a7488 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 116
33  CoreFoundation                       0x000000018215a0c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
34  CoreFoundation                       0x0000000182157cf0 __CFRunLoopDoObservers + 368
35  CoreFoundation                       0x00000001820862d8 CFRunLoopRunSpecific + 472
36  GraphicsServices                     0x0000000183b3a198 GSEventRunModal + 176
37  UIKit                                0x00000001880cd7fc -[UIApplication _run] + 680
38  UIKit                                0x00000001880c8534 UIApplicationMain + 204
39  XXXXXXXXX                            0x00000001001d5c08 main (main.m:15)
40  libdyld.dylib                        0x00000001810695b8 start + 0

...

Thread 25 Crashed:
0   libsystem_kernel.dylib               0x000000018117b014 __pthread_kill + 8
1   libsystem_pthread.dylib              0x0000000181243450 pthread_kill + 108
2   libsystem_c.dylib                    0x00000001810ef400 abort + 136
3   HockeySDK                            0x0000000100ee3888 uncaught_exception_handler + 28
4   HockeySDK                            0x0000000100e81b24 uncaught_cxx_exception_handler (BITCrashManager.m:180)
5   HockeySDK                            0x0000000100ece68c BITCrashUncaughtCXXTerminateHandler() (BITCrashCXXExceptionHandler.mm:124)
6   libc++abi.dylib                      0x0000000180bd366c std::__terminate(void (*)()) + 16
7   libc++abi.dylib                      0x0000000180bd3234 __cxa_rethrow + 140
8   Mapbox                               0x00000001014b4c6c mbgl::OfflineDatabase::ensureSchema() (offline_database.cpp:62)
9   Mapbox                               0x00000001014b48bc mbgl::OfflineDatabase::OfflineDatabase(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long) (offline_database.cpp:24)
10  Mapbox                               0x00000001014a5b00 void mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::run<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>, 0ul, 1ul>(std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>&&, std::__1::integer_sequence<unsigned long, 0ul, 1ul>) (default_file_source.cpp:29)
11  Mapbox                               0x00000001014a5a64 std::__1::__thread_proxy<std::__1::tuple<mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::Thread<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>(mbgl::util::ThreadContext const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&, unsigned long long&&&)::'lambda'()> >(void*, void*) (thread.hpp:110)
12  libsystem_pthread.dylib              0x0000000181241850 _pthread_body + 236
13  libsystem_pthread.dylib              0x0000000181241760 _pthread_start + 280
14  libsystem_pthread.dylib              0x000000018123ed94 thread_start + 0

...

Binary Images:
...
       0x10136c000 -        0x101517fff +Mapbox arm64  <eaf92e638e7d3ed68a1febf24da6234a> /private/var/containers/Bundle/Application/EFB6C989-526D-4F54-A5D1-C87EBE28E1E1/XXX.app/Frameworks/Mapbox.framework/Mapbox

Let me know if there's any additional information needed or if this is a duplicate crash report that I missed when searching the existing issues. Thanks!

@friedbunny friedbunny added crash iOS Mapbox Maps SDK for iOS offline labels Feb 1, 2017
@erichoracek
Copy link
Contributor Author

Something else to note is that we are not using any offline storage functionality, e.g. MGLOfflineStorage or other related classes.

@friedbunny
Copy link
Contributor

Thanks for the report, @erichoracek. And sorry, I meant to immediately explain the tag: I added offline because there isn’t currently a database/SQLite/storage tag, though perhaps we should have one.

/cc @jfirebaugh @ericrwolfe

@erichoracek
Copy link
Contributor Author

Just to update the status of this on our end, we reached out to the affected user and asked them to uninstall/reinstall. This fixed the crash for them.

@repomies
Copy link

repomies commented Apr 5, 2017

Maybe related, maybe something else, but after my app updated from Mapbox iOS SDK 3.3.7 to 3.5.0, my existing users started getting a crash in mbgl::OfflineDatabase::ensureSchema() for unknown schema version. (No offline storage being explicitly used in my app.)

Edit: Works now. Probably this was caused by the old app version having newer Mapbox SDK than the update, after all. (You know, the SDK being so big it needs to be gitignored, and CocoaPods not updating the SDK because of a Podfile.lock that was updated on a different machine… My bad.)

@RomainQuidet
Copy link
Contributor

RomainQuidet commented Apr 24, 2017

@friedbunny Still seeing this issue on the field with some customers. We moved from 3.4 to 3.5.2.

Application Specific Information:

*** Terminating app due to uncaught exception 'mapbox::sqlite::Exception', reason: 'database disk image is malformed'

Last Exception Backtrace:
0   Mappy                                0x0000000100377ac4 mapbox::sqlite::Statement::run() + 148
1   Mappy                                0x000000010036de3c mbgl::OfflineDatabase::getTile(mbgl::Resource::TileData const&) + 188
2   Mappy                                0x000000010036dca4 mbgl::OfflineDatabase::get(mbgl::Resource const&) + 40
3   Mappy                                0x00000001003604d4 mbgl::DefaultFileSource::Impl::request(mbgl::AsyncRequest*, mbgl::Resource, std::__1::function<void (mbgl::Response)>) + 112
4   Mappy                                0x0000000100361140 mbgl::DefaultFileSource::Impl::request(mbgl::AsyncRequest*, mbgl::Resource, std::__1::function<void (mbgl::Response)>) + 3292
5   Mappy                                0x0000000100358b3c mbgl::util::RunLoop::process() + 224
6   CoreFoundation                       0x000000019147d424 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 20
7   CoreFoundation                       0x000000019147cd94 __CFRunLoopDoSources0 + 536
8   CoreFoundation                       0x000000019147a9a0 __CFRunLoopRun + 740
9   CoreFoundation                       0x00000001913aad94 CFRunLoopRunSpecific + 420
10  CoreFoundation                       0x00000001913f79a0 CFRunLoopRun + 108
11  Mappy                                0x0000000100360204 void mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::run<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>, 0ul, 1ul>(std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>&&, std::__1::integer_sequence<unsigned long, 0ul, 1ul>) + 104
12  Mappy                                0x0000000100360158 std::__1::__thread_proxy<std::__1::tuple<mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::Thread<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>(mbgl::util::ThreadContext const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&, unsigned long long&&&)::'lambda'()> >(void*, void*) + 116
13  libsystem_pthread.dylib              0x000000019059175c _pthread_body + 236
14  libsystem_pthread.dylib              0x000000019059166c _pthread_start + 280
15  libsystem_pthread.dylib              0x000000019058ed84 thread_start + 0

@Sealos
Copy link

Sealos commented Aug 14, 2017

I'm also seeing this issue on Mapbox 3.6. Can't reproduce locally, however, we've seen plenty of crashes in fabric due to this exception.

Fatal Exception: mapbox::sqlite::Exception: database disk image is malformed

#19. Crashed: DefaultFileSource
0  XXXXXXXX                       0x420307 CLSProcessRecordAllThreads (CLSProcess.c:376)
1  XXXXXXXX                       0x420307 CLSProcessRecordAllThreads (CLSProcess.c:376)
2  XXXXXXXX                       0x4201f9 CLSProcessRecordAllThreads (CLSProcess.c:407)
3  XXXXXXXX                       0x4148eb CLSHandler (CLSHandler.m:26)
4  XXXXXXXX                       0x41ec73 __CLSExceptionRecord_block_invoke (CLSException.mm:199)
5  libdispatch.dylib              0x1ade2083 _dispatch_client_callout + 22
6  libdispatch.dylib              0x1adee33b _dispatch_barrier_sync_f_invoke + 50
7  XXXXXXXX                       0x41e673 CLSExceptionRecord (CLSException.mm:206)
8  XXXXXXXX                       0x41e181 CLSTerminateHandler() (CLSException.mm:265)
9  libc++abi.dylib                0x1a99393f std::__terminate(void (*)()) + 78
10 libc++abi.dylib                0x1a993443 __cxa_rethrow + 90
11 libobjc.A.dylib                0x1a99f1bb objc_exception_rethrow + 42
12 CoreFoundation                 0x1b6455a1 CFRunLoopRunSpecific + 596
13 CoreFoundation                 0x1b6879d9 CFRunLoopRun + 104
14 Mapbox                         0xc3a3dd void mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::run<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>, 0ul, 1ul>(std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>&&, std::__1::integer_sequence<unsigned long, 0ul, 1ul>) + 408
15 Mapbox                         0xc3a2e5 std::__1::__thread_proxy<std::__1::tuple<mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::Thread<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>(mbgl::util::ThreadContext const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&, unsigned long long&&&)::'lambda'()> >(void*, void*) + 160
16 libsystem_pthread.dylib        0x1af99a27 _pthread_body + 216
17 libsystem_pthread.dylib        0x1af9994d _pthread_start + 234
18 libsystem_pthread.dylib        0x1af9749c thread_start + 8

@asetiyadi
Copy link

Have anyone found a solution to this issue? Experiencing the same issue and it is the top crash in our app. Appreciate the info.

@Luchkovskaya
Copy link

We experience the same issue , but we are not using Offline maps. "Fatal Exception: mapbox::sqlite::Exception: database disk image is malformed"

@Sealos
Copy link

Sealos commented Oct 2, 2017

Any workaround to this issue?

@boundsj
Copy link
Contributor

boundsj commented Oct 2, 2017

@Sealos @Luchkovskaya @asetiyadi and others who have reported: If you can say if you are linking the Mapbox framework statically or dynamically that may help us with our investigation of this issue.

@RomainQuidet
Copy link
Contributor

RomainQuidet commented Oct 2, 2017 via email

@Sealos
Copy link

Sealos commented Oct 3, 2017

Dynamic framework.

@Luchkovskaya
Copy link

Dynamic framework

@chriszhang4213
Copy link

Do we fix this issue? we just updated to 3.6. seems like it still has this issue, i just got 4 crash report for this. and we are using dynamically framework.

@Sealos
Copy link

Sealos commented Oct 12, 2017

Fabric reports that most crashes originate from devices with low RAM, could that be of help?

@boundsj
Copy link
Contributor

boundsj commented Oct 12, 2017

Thanks all for the reports. The fact that this issue is still open indicates that it is not resolved. This issue will stay open until it is resolved.

@MarkPolivchuk
Copy link

MarkPolivchuk commented Jan 18, 2018

I'm also experiencing this issue on the latest release. So far I've only seen it on my iPhone 5c.

Edit: I also got a "Storage Low" warning shortly after experiencing it. Could it have to do with that?

@kkaefer
Copy link
Member

kkaefer commented Feb 13, 2018

This error may be caused when linking another copy of SQLite into your application in addition to the system version of SQLite. Linking a third-party version of SQLite in addition to the system version isn't a supported use case, and the SQLite documentation specifically warns against that. Some third party libraries ship with their own version of SQLite, e.g. SQLCipher. The authors of SQLCipher have concluded similarly and advise against using it with system-SQLite.

To check what other libraries include their own copies of SQLite, you can use include this code somewhere in your bundle (it will run automatically, no need to call it):

#include <sqlite3.h>
#include <dlfcn.h>
#include <mach-o/dyld.h>

__attribute__((constructor)) void check_linked_sqlite_libs() {
    void* system_handle = dlopen("/usr/lib/libsqlite3.dylib", RTLD_LOCAL);
    assert(system_handle);
    void* system_symbol = dlsym(system_handle, "sqlite3_initialize");
    assert(system_symbol);

    for (int i = 0, c = _dyld_image_count(); i < c; i++) {
        const char* name = _dyld_get_image_name(i);
        void* handle = dlopen(name, RTLD_LOCAL);
        if (!handle) continue;
        void* symbol = dlsym(handle, "sqlite3_initialize");
        if (!symbol) continue;

        if (symbol != system_symbol || handle == system_handle) {
            fprintf(stderr, "%s SQLite in %s: %p\n", symbol == &sqlite3_initialize ? "default" : "duplicate", name, symbol);
        }
    }
}

If you're experiencing this crash, please report back here with the results of the above code, and a brief summary of what third party libraries you're using, and how you're linking them, as well as how you're using SQLite in the rest of your application and how you're linking it.

@JesseCrocker
Copy link
Contributor

I've seen this come up in my application, which does not does link a second copy of SQLite, and it it does correlated to users filling up device storage.

default SQLite in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libsqlite3.dylib: 0x10ca037a0

@kkaefer
Copy link
Member

kkaefer commented Aug 15, 2018

This should be fixed by #12224.

@kkaefer kkaefer closed this as completed Aug 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crash iOS Mapbox Maps SDK for iOS offline
Projects
None yet
Development

No branches or pull requests