mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Multiple Maps cause SQLLite cache(22): SIGBART error

Open jonathanduty opened this issue 11 years ago • 14 comments

Setup: I modified the left and right navbar buttons to either push a new MBXViewController or pop it using the UINavigationController. I wanted to test navigating from one map to another using push/pop UINavigation controller.

Bug One: Open the App. Let the map fully load. Then push right nav button and navigate to next map. Start dragging quickly. You will eventually get a SQLLite cache(22): SIGBART error.

SQLite Cache (28)#0 0x0333269a in __pthread_kill ()
#1  0x03360f19 in pthread_kill ()
#2  0x030d9a5a in abort ()
#3  0x0336f527 in abort_message ()
#4  0x03392631 in default_terminate_handler() ()
#5  0x02c30d58 in _objc_terminate() ()
#6  0x0338fcf0 in std::__terminate(void (*)()) ()
#7  0x0338f70f in __cxa_throw ()
#8  0x003bcefb in mapbox::sqlite::Statement::run() at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/platform/default/sqlite3.cpp:146
#9  0x003b0c9b in mbgl::SQLiteCache::process(mbgl::SQLiteCache::RefreshAction&) at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/platform/default/sqlite_cache.cpp:262
#10 0x003ba91b in void mbgl::SQLiteCache::ActionDispatcher::operator()<mbgl::SQLiteCache::RefreshAction>(mbgl::SQLiteCache::RefreshAction&) at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/platform/default/sqlite_cache.cpp:88
#11 0x003ba896 in mapbox::util::detail::dispatcher<mbgl::SQLiteCache::ActionDispatcher, mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>, void, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>::apply(mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&, mbgl::SQLiteCache::ActionDispatcher) at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/include/mbgl/util/variant.hpp:277
#12 0x003ba687 in mapbox::util::detail::dispatcher<mbgl::SQLiteCache::ActionDispatcher, mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>, void, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>::apply(mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&, mbgl::SQLiteCache::ActionDispatcher) at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/include/mbgl/util/variant.hpp:281
#13 0x003ba417 in mapbox::util::detail::dispatcher<mbgl::SQLiteCache::ActionDispatcher, mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>, void, mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>::apply(mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&, mbgl::SQLiteCache::ActionDispatcher) at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/include/mbgl/util/variant.hpp:281
#14 0x003ba36e in decltype(detail::dispatcher<mbgl::SQLiteCache::ActionDispatcher, mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>, mapbox::util::detail::result_of_unary_visit<mbgl::SQLiteCache::ActionDispatcher, mbgl::SQLiteCache::GetAction, void>::type, mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>::apply(fpfp0)) mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>::visit<mbgl::SQLiteCache::ActionDispatcher, mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction> >(mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&, mbgl::SQLiteCache::ActionDispatcher) at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/include/mbgl/util/variant.hpp:694
#15 0x003b276e in decltype(mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>::visit(fp0fp)) mapbox::util::apply_visitor<mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>, mbgl::SQLiteCache::ActionDispatcher>(mbgl::SQLiteCache::ActionDispatcher, mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&) at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/include/mbgl/util/variant.hpp:760
#16 0x003b2704 in mbgl::SQLiteCache::SQLiteCache(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0::operator()(mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&) const at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/platform/default/sqlite_cache.cpp:95
#17 0x003b25a9 in std::__1::__invoke<mbgl::SQLiteCache::SQLiteCache(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0&, mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&>(decltype(std::__1::forward<mbgl::SQLiteCache::SQLiteCache(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0&>(fp)(std::__1::forward<mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&>(fp0))), mbgl::SQLiteCache::SQLiteCache(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0&&&, mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__functional_base:413
#18 0x003b2588 in std::__1::__function::__func<mbgl::SQLiteCache::SQLiteCache(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0, std::__1::allocator<mbgl::SQLiteCache::SQLiteCache(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>, void (mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&)>::operator()(mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1370
#19 0x003b9f28 in std::__1::function<void (mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&)>::operator()(mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&) const at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1755
#20 0x003b9d1e in mbgl::util::AsyncQueue<mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction> >::process() at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/include/mbgl/util/async_queue.hpp:81
#21 0x003b98c2 in mbgl::util::AsyncQueue<mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction> >::AsyncQueue(uv_loop_s*, std::__1::function<void (mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&)>)::'lambda'(uv_async_s*, int)::operator()(uv_async_s*, int) const at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/include/mbgl/util/async_queue.hpp:32
#22 0x003b985e in mbgl::util::AsyncQueue<mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction> >::AsyncQueue(uv_loop_s*, std::__1::function<void (mapbox::util::variant<mbgl::SQLiteCache::GetAction, mbgl::SQLiteCache::PutAction, mbgl::SQLiteCache::RefreshAction, mbgl::SQLiteCache::StopAction>&)>)::'lambda'(uv_async_s*, int)::__invoke(uv_async_s*, int) at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/include/mbgl/util/async_queue.hpp:30
#23 0x003bdaef in uv__async_event at /Users/kkaefer/Code/mason/libuv-0.10.28/mason_packages/.build/libuv-0.10.28/src/unix/async.c:80
#24 0x003bdf37 in uv__async_io at /Users/kkaefer/Code/mason/libuv-0.10.28/mason_packages/.build/libuv-0.10.28/src/unix/async.c:156
#25 0x003db5fb in uv__io_poll at /Users/kkaefer/Code/mason/libuv-0.10.28/mason_packages/.build/libuv-0.10.28/src/unix/kqueue.c:233
#26 0x003be6da in uv_run at /Users/kkaefer/Code/mason/libuv-0.10.28/mason_packages/.build/libuv-0.10.28/src/unix/core.c:317
#27 0x003b15e8 in mbgl::SQLiteCache::SQLiteCache(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_1::operator()() const at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/platform/default/sqlite_cache.cpp:101
#28 0x003b13a5 in std::__1::__thread_proxy<std::__1::tuple<mbgl::SQLiteCache::SQLiteCache(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_1> >(void*, void*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2602
#29 0x0335ee13 in _pthread_body ()
#30 0x0335ed89 in _pthread_start ()
#31 0x0335ce52 in thread_start ()

jonathanduty avatar Mar 25 '15 19:03 jonathanduty

/cc @kkaefer

bleege avatar Mar 25 '15 19:03 bleege

Are you still seeing this @jonathanduty?

bleege avatar Apr 17 '15 21:04 bleege

Can confirm I'm also getting an identical error.

bsudekum avatar Apr 28 '15 16:04 bsudekum

This shouldn't be happening anymore since https://github.com/mapbox/mapbox-gl-native/commit/4b66c490b41e8ea18428828707ed4327734f92dc. Do you have a recent build, @bsudekum?

However, the root cause still exists: Our Cocoa Map objects still encapsulate everything, so they create a separate FileSource (and FileCache) object for every Map view. Instead, when they use the same database file, they should use the same FileCache object. /cc @incanus

kkaefer avatar Apr 28 '15 16:04 kkaefer

New build rolled last night, update yer pods.

incanus avatar Apr 28 '15 16:04 incanus

:+1: . Updating pod now and checking

bsudekum avatar Apr 28 '15 16:04 bsudekum

Working fine for me now. @jonathanduty good to close?

bsudekum avatar Apr 28 '15 16:04 bsudekum

No. The original issue still exists. See my comment above.

kkaefer avatar Apr 28 '15 17:04 kkaefer

2015-04-29 13:17:47.939 Embark[11491:15975096] [ERROR] Database: database is locked 2015-04-29 13:17:47.996 Embark[11491:15975096] [ERROR] Database: database is locked 2015-04-29 13:17:48.264 Embark[11491:15975096] [ERROR] Database: database is locked 2015-04-29 13:17:48.558 Embark[11491:15975096] [ERROR] Database: database is locked

And crash in:

__mutex_base

    _LIBCPP_INLINE_VISIBILITY
    explicit lock_guard(mutex_type& __m)
        : __m_(__m) {__m_.lock();} <<<<<<< STOP HERE
    _LIBCPP_INLINE_VISIBILITY
    lock_guard(mutex_type& __m, adopt_lock_t)
        : __m_(__m) {}
    _LIBCPP_INLINE_VISIBILITY
    ~lock_guard() {__m_.unlock();}

robipresotto avatar Apr 29 '15 11:04 robipresotto

I still see database locking problems as well in https://github.com/incanus/PushTest as of https://github.com/incanus/PushTest/commit/2ae2e253b7b985d9cc3976c79c3b7227d9a51e8a. Investigating along with #1103.

incanus avatar Apr 29 '15 21:04 incanus

Does that project create more than one Map view?

kkaefer avatar Apr 29 '15 21:04 kkaefer

Yes, though via VC pushes, so only momentarily. However, when you've pushed one onto the nav stack, you can go back to the still-existent first one. I will also build out something which does two maps in the same viewport.

incanus avatar Apr 30 '15 15:04 incanus

As indicated above, the issue is:

Our Cocoa Map objects still encapsulate everything, so they create a separate FileSource (and FileCache) object for every Map view. Instead, when they use the same database file, they should use the same FileCache object.

kkaefer avatar Apr 30 '15 15:04 kkaefer

Yep, going to go for this since we can't have 2+ map objects writing to the same file safely otherwise.

incanus avatar Apr 30 '15 15:04 incanus