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

Changing style repeatedly consistently causes crash. #788

Closed

Description

@mb12

Here is how to reproduce it consistently.

  1. Launch sample iosapp.
  2. Keep tapping on the center of the navigation bar to change styles.
  3. It consistently crashes after 10 or so style switches.

I have copy pasted the lldb stack traces for the crashes below. I've included two unique stack traces.

Crash number 1

eneral: painter setup: 0.057500000000000002ms
libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc
(lldb) bt
* thread #35: tid = 0x40a830, 0x3a90b1f0 libsystem_kernel.dylib`__pthread_kill + 8, name = 'Map', stop reason = signal SIGABRT
    frame #0: 0x3a90b1f0 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x3a975796 libsystem_pthread.dylib`pthread_kill + 58
    frame #2: 0x3a8bbfdc libsystem_c.dylib`abort + 76
    frame #3: 0x39beacd6 libc++abi.dylib`abort_message + 74
    frame #4: 0x39c036e4 libc++abi.dylib`default_terminate_handler() + 252
    frame #5: 0x3a348f88 libobjc.A.dylib`_objc_terminate() + 228
    frame #6: 0x39c011c6 libc++abi.dylib`std::__terminate(void (*)()) + 78
    frame #7: 0x39c00a1c libc++abi.dylib`__cxa_throw + 116
    frame #8: 0x006ee7c0 libglInterpose.dylib`operator new(unsigned long) + 160
  * frame #9: 0x00086188 Mapbox GL`std::__1::__split_buffer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&) [inlined] std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::allocate(this=0x1a9445b8, __n=357913941, (null)=0x00000000) + 180 at memory:1630
    frame #10: 0x0008617a Mapbox GL`std::__1::__split_buffer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&) [inlined] std::__1::__split_buffer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&>::__alloc(this=0x03741968, __a=0x1a9445b8, __n=357913941) + 10 at memory:1435
    frame #11: 0x00086170 Mapbox GL`std::__1::__split_buffer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&>::__split_buffer(this=0x03741968, __cap=357913941, __start=78261014, __a=0x1a9445b8) + 156 at __split_buffer:325
    frame #12: 0x00085482 Mapbox GL`std::__1::__split_buffer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&>::__split_buffer(this=0x03741968, __cap=357913941, __start=78261014, __a=0x1a9445b8) + 50 at __split_buffer:328
    frame #13: 0x001e8194 Mapbox GL`void std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::__emplace_back_slow_path<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(this=0x1a9445b0, __args=0x03741b2c) + 404 at vector:1572
    frame #14: 0x001e76f8 Mapbox GL`mbgl::parse(rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, char const*) [inlined] std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(this=0x03741b2c, this=0x1a9445b0, __s=0x080d8698, __args=0x03741b2c, __n=183) + 310 at vector:1593
    frame #15: 0x001e75c2 Mapbox GL`mbgl::parse(value=0x03741d04, target=0x1a9445b0, name=0x0026efa0) + 378 at style_source.cpp:22
    frame #16: 0x001e7b1a Mapbox GL`mbgl::SourceInfo::parseTileJSONProperties(this=0x1a9445a0, value=0x03741d04) + 54 at style_source.cpp:69
    frame #17: 0x000db480 Mapbox GL`mbgl::Source::load(this=0x1aa4403c, res=0x1aa44380)::$_0::operator()(mbgl::Response const&) const + 388 at source.cpp:56
    frame #18: 0x000db238 Mapbox GL`std::__1::__function::__func<mbgl::Source::load(mbgl::Map&, mbgl::FileSource&)::$_0, std::__1::allocator<mbgl::Source::load(mbgl::Map&, mbgl::FileSource&)::$_0>, void (mbgl::Response const&)>::operator()(mbgl::Response const&) [inlined] decltype(this=0x1aa4403c, __f=0x1aa4403c, __args=0x1aa44380)::$_0&>(fp)(std::__1::forward<mbgl::Response const&>(fp0))) std::__1::__invoke<mbgl::Source::load(mbgl::Map&, mbgl::FileSource&)::$_0&, mbgl::Response const&>(mbgl::Source::load(mbgl::Map&, mbgl::FileSource&)::$_0&&&, mbgl::Response const&&&) + 16 at __functional_base:413
    frame #19: 0x000db228 Mapbox GL`std::__1::__function::__func<mbgl::Source::load(this=0x1aa44038, __arg=0x1aa44380)::$_0, std::__1::allocator<mbgl::Source::load(mbgl::Map&, mbgl::FileSource&)::$_0>, void (mbgl::Response const&)>::operator()(mbgl::Response const&) + 48 at functional:1370
    frame #20: 0x00189d46 Mapbox GL`std::__1::function<void (this=0x1aa44038, __arg=0x1aa44380)>::operator()(mbgl::Response const&) const + 158 at functional:1755
    frame #21: 0x00189998 Mapbox GL`void mbgl::invoke<std::__1::function<void (list=0x03741f64, args=0x1aa44380)>, mbgl::Response&>(std::__1::forward_list<std::__1::unique_ptr<mapbox::util::variant<std::__1::function<void (mbgl::Response const&)>, std::__1::function<void ()> >, std::__1::default_delete<mapbox::util::variant<std::__1::function<void (mbgl::Response const&)>, std::__1::function<void ()> > > >, std::__1::allocator<std::__1::unique_ptr<mapbox::util::variant<std::__1::function<void (mbgl::Response const&)>, std::__1::function<void ()> >, std::__1::default_delete<mapbox::util::variant<std::__1::function<void (mbgl::Response const&)>, std::__1::function<void ()> > > > > > const&, mbgl::Response&&&) + 324 at base_request.cpp:17
    frame #22: 0x00188e10 Mapbox GL`mbgl::BaseRequest::notify(this=0x1aa438ec) + 436 at base_request.cpp:49
    frame #23: 0x00193778 Mapbox GL`mbgl::HTTPRequest::handleCacheResponse(this=0x1aa438ec, res=0x1aa43bf0) + 600 at http_request.cpp:58
    frame #24: 0x001959d2 Mapbox GL`mbgl::HTTPRequest::startCacheRequest(this=0x1a800430, response_=0x1aa43bf0, ptr=0x1a800430)::$_0::operator()(std::__1::unique_ptr<mbgl::Response, std::__1::default_delete<mbgl::Response> >&&, void*) const + 250 at http_request.cpp:44
    frame #25: 0x001958bc Mapbox GL`mbgl::HTTPRequest::startCacheRequest(response_=0x1aa43bf0, ptr=0x1a800430)::$_0::__invoke(std::__1::unique_ptr<mbgl::Response, std::__1::default_delete<mbgl::Response> >&&, void*) + 40 at http_request.cpp:39
    frame #26: 0x0019a64a Mapbox GL`mbgl::SQLiteStore::get(this=0x0019a505, data=0x1aa43bd0)(std::__1::unique_ptr<mbgl::Response, std::__1::default_delete<mbgl::Response> >&&, void*), void*)::$_2::operator()(void*) const + 262 at sqlite_store.cpp:149
    frame #27: 0x0019a528 Mapbox GL`mbgl::SQLiteStore::get(data=0x1aa43bd0)(std::__1::unique_ptr<mbgl::Response, std::__1::default_delete<mbgl::Response> >&&, void*), void*)::$_2::__invoke(void*) + 36 at sqlite_store.cpp:146
    frame #28: 0x002326aa Mapbox GL`uv__worker_after(ptr=0x1a800450) + 130 at uv-worker.c:56
    frame #29: 0x00232398 Mapbox GL`uv__messenger_callback(async=0x1a8003bc, status=0) + 104 at uv-messenger.c:37
    frame #30: 0x0023917e Mapbox GL`uv__async_event(loop=0x1566fbe0, w=0x1566fcb8, nevents=2) + 126 at async.c:80
    frame #31: 0x00239426 Mapbox GL`uv__async_io(loop=0x1566fbe0, w=0x1566fcbc, events=1) + 190 at async.c:156
    frame #32: 0x0024c20c Mapbox GL`uv__io_poll(loop=0x1566fbe0, timeout=-1) + 2252 at kqueue.c:233
    frame #33: 0x002398e6 Mapbox GL`uv_run(loop=0x1566fbe0, mode=UV_RUN_DEFAULT) + 130 at core.c:317
    frame #34: 0x000c3a5a Mapbox GL`mbgl::Map::run(this=0x1566fa50) + 330 at map.cpp:238
    frame #35: 0x000c9860 Mapbox GL`mbgl::Map::start(this=0x1a8a3290)::$_5::operator()() const + 192 at map.cpp:189
    frame #36: 0x000c9656 Mapbox GL`void* std::__1::__thread_proxy<std::__1::tuple<mbgl::Map::start(__vp=0x1a8a3290)::$_5> >(void*) + 274 at memory:2602
    frame #37: 0x3a974918 libsystem_pthread.dylib`_pthread_body + 140
    frame #38: 0x3a97488a libsystem_pthread.dylib`_pthread_start + 102
    frame #39: 0x3a972aa4 libsystem_pthread.dylib`thread_start + 8
(lldb) 

Crash number 2

Assertion failed: (std::this_thread::get_id() == thread_id), function cancel, file /Users/mb/Documents/MAPBOX_MASON_SCRATCH/mapbox-gl-native/src/mbgl/storage/http_request.cpp, line 264.

(lldb) bt
* thread #37: tid = 0x40ac23, 0x3a90b1f0 libsystem_kernel.dylib`__pthread_kill + 8, name = 'Map', stop reason = signal SIGABRT
    frame #0: 0x3a90b1f0 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x3a975796 libsystem_pthread.dylib`pthread_kill + 58
    frame #2: 0x3a8bbfdc libsystem_c.dylib`abort + 76
    frame #3: 0x3a89bcae libsystem_c.dylib`__assert_rtn + 182
  * frame #4: 0x00192ed8 Mapbox GL`mbgl::HTTPRequest::cancel(this=0x15df979c) + 228 at http_request.cpp:264
    frame #5: 0x001894c6 Mapbox GL`mbgl::CachingHTTPFileSource::clearLoop(this=0x15d56260) + 778 at caching_http_file_source.cpp:51
    frame #6: 0x000c97ce Mapbox GL`mbgl::Map::start(this=0x1b0782cc)::$_3::operator()() const + 574 at map.cpp:154
    frame #7: 0x000c94cc Mapbox GL`std::__1::__function::__func<mbgl::Map::start()::$_3, std::__1::allocator<mbgl::Map::start()::$_3>, void ()>::operator()() [inlined] decltype(this=0x1b0782cc, __f=0x1b0782cc)::$_3&>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<mbgl::Map::start()::$_3&>(mbgl::Map::start()::$_3&&&) + 10 at __functional_base:413
    frame #8: 0x000c94c2 Mapbox GL`std::__1::__function::__func<mbgl::Map::start(this=0x1b0782c8)::$_3, std::__1::allocator<mbgl::Map::start()::$_3>, void ()>::operator()() + 38 at functional:1370
    frame #9: 0x0018ca1e Mapbox GL`std::__1::function<void (this=0x1b0782c8)>::operator()() const + 146 at functional:1755
    frame #10: 0x000cfab8 Mapbox GL`uv::async::async_cb(a=0x1b078310, (null)=0) + 36 at uv_detail.hpp:81
    frame #11: 0x0023717e Mapbox GL`uv__async_event(loop=0x15d56820, w=0x15d568f8, nevents=1) + 126 at async.c:80
    frame #12: 0x00237426 Mapbox GL`uv__async_io(loop=0x15d56820, w=0x15d568fc, events=1) + 190 at async.c:156
    frame #13: 0x0024a20c Mapbox GL`uv__io_poll(loop=0x15d56820, timeout=-1) + 2252 at kqueue.c:233
    frame #14: 0x002378e6 Mapbox GL`uv_run(loop=0x15d56820, mode=UV_RUN_DEFAULT) + 130 at core.c:317
    frame #15: 0x000c1a5a Mapbox GL`mbgl::Map::run(this=0x15d56690) + 330 at map.cpp:238
    frame #16: 0x000c7860 Mapbox GL`mbgl::Map::start(this=0x1b07b0b0)::$_5::operator()() const + 192 at map.cpp:189
    frame #17: 0x000c7656 Mapbox GL`void* std::__1::__thread_proxy<std::__1::tuple<mbgl::Map::start(__vp=0x1b07b0b0)::$_5> >(void*) + 274 at memory:2602
    frame #18: 0x3a974918 libsystem_pthread.dylib`_pthread_body + 140
    frame #19: 0x3a97488a libsystem_pthread.dylib`_pthread_start + 102
(lldb) 

Activity

  1. ljbade commented on Jan 29, 2015

    @ljbade
    Contributor

    Looks like the app is running out of memory. I know @kkaefer has been trying to track down a memory leak.

    /cc @incanus

  2. mb12 commented on Jan 29, 2015

    @mb12
    Author

    The second stack trace is an assert failure (The first one is most likely out of memory (std::bad_alloc)).

    Assertion failed: (std::this_thread::get_id() == thread_id), function cancel, file /Users/mb/Documents/MAPBOX_MASON_SCRATCH/mapbox-gl-native/src/mbgl/storage/http_request.cpp, line 264.

  3. mb12 commented on Jan 29, 2015

    @mb12
    Author

    @ljbade Should I file a separate issue for stack trace 2?
    I've updated the title to accurately reflect your stack trace 1 analysis.

  4. ljbade commented on Jan 29, 2015

    @ljbade
    Contributor

    I have seen that second crash before. I believe it happens when a tile finished loading after the map changes style. @kkaefer is also working to refactor that code.

  5. mb12 commented on Feb 5, 2015

    @mb12
    Author

    @kkaefer Can you please let me know if the following commit addresses this/similar issues?

    b9bf66e

  6. mb12 commented on Feb 5, 2015

    @mb12
    Author

    These are not fixed in the latest build. The crash can be trivially reproduced by switching styles in the sample app. I've included the stack track with the latest one.

    (lldb) bt
    * thread #52: tid = 0x4fbc6b, 0x001f1ac8 Mapbox GL`uv_worker_send(worker=0xe17de488, data=0x17e2b700, work_cb=0x000ac11d, after_work_cb=0x000ac161) + 20 at uv-worker.c:138, name = 'Map', stop reason = EXC_BAD_ACCESS (code=1, address=0xe17de488)
        frame #0: 0x001f1ac8 Mapbox GL`uv_worker_send(worker=0xe17de488, data=0x17e2b700, work_cb=0x000ac11d, after_work_cb=0x000ac161) + 20 at uv-worker.c:138
        frame #1: 0x000ac0fe Mapbox GL`uv::worker::add(this=0x17d68880, data=0x17e2b700, work_cb=0x000ac11d, after_work_cb=0x000ac161)(void*), void (*)(void*)) + 50 at uv_detail.hpp:136
        frame #2: 0x000abfea Mapbox GL`uv::work<mbgl::util::ptr<mbgl::TileData> >::work<std::__1::shared_ptr<mbgl::TileData> >(this=0x17e2b700, worker=0x17d68880, work_cb_=<unavailable>, after_work_cb_=<unavailable>, args=0x033171e8)>, std::__1::function<void (mbgl::util::ptr<mbgl::TileData>&)>, std::__1::shared_ptr<mbgl::TileData>&&) + 230 at uv_detail.hpp:154
        frame #3: 0x000abea2 Mapbox GL`uv::work<mbgl::util::ptr<mbgl::TileData> >::work<std::__1::shared_ptr<mbgl::TileData> >(this=0x17e2b700, worker=0x17d68880, work_cb_=<unavailable>, after_work_cb_=<unavailable>, args=0x033171e8)>, std::__1::function<void (mbgl::util::ptr<mbgl::TileData>&)>, std::__1::shared_ptr<mbgl::TileData>&&) + 58 at uv_detail.hpp:155
        frame #4: 0x000a7b6a Mapbox GL`mbgl::TileData::reparse(this=0x17dfa3ac, worker=0x17d68880, callback=<unavailable>)>) + 226 at tile_data.cpp:96
        frame #5: 0x000aaeaa Mapbox GL`mbgl::TileData::request(this=0x17d66e38, res=0x17d5f3c0)>)::$_1::operator()(mbgl::Response const&) const + 478 at tile_data.cpp:75
        frame #6: 0x000aac04 Mapbox GL`std::__1::__function::__func<mbgl::TileData::request(uv::worker&, uv_loop_s&, float, std::__1::function<void ()>)::$_1, std::__1::allocator<mbgl::TileData::request(uv::worker&, uv_loop_s&, float, std::__1::function<void ()>)::$_1>, void (mbgl::Response const&)>::operator()(mbgl::Response const&) [inlined] decltype(this=0x17d66e38, __f=0x17d66e38, __args=0x17d5f3c0)>)::$_1&>(fp)(std::__1::forward<mbgl::Response const&>(fp0))) std::__1::__invoke<mbgl::TileData::request(uv::worker&, uv_loop_s&, float, std::__1::function<void ()>)::$_1&, mbgl::Response const&>(mbgl::TileData::request(uv::worker&, uv_loop_s&, float, std::__1::function<void ()>)::$_1&&&, mbgl::Response const&&&) + 16 at __functional_base:413
        frame #7: 0x000aabf4 Mapbox GL`std::__1::__function::__func<mbgl::TileData::request(this=0x17d66e30, __arg=0x17d5f3c0)>)::$_1, std::__1::allocator<mbgl::TileData::request(uv::worker&, uv_loop_s&, float, std::__1::function<void ()>)::$_1>, void (mbgl::Response const&)>::operator()(mbgl::Response const&) + 48 at functional:1370
        frame #8: 0x00151b26 Mapbox GL`std::__1::function<void (this=0x17d377e0, __arg=0x17d5f3c0)>::operator()(mbgl::Response const&) const + 158 at functional:1755
        frame #9: 0x001510ec Mapbox GL`mbgl::Request::notifyCallback(async=0x17d83870) + 152 at request.cpp:39
        frame #10: 0x00151a26 Mapbox GL`mbgl::Request::Request(this=0x00000000, async=0x17d83870, (null)=0)>)::$_0::operator()(uv_async_s*, int) const + 34 at request.cpp:24
      * frame #11: 0x001519e8 Mapbox GL`mbgl::Request::Request(async=0x17d83870, (null)=0)>)::$_0::__invoke(uv_async_s*, int) + 40 at request.cpp:24
        frame #12: 0x00223d72 Mapbox GL`uv__async_event(loop=0x17e217e0, w=0x17e218b8, nevents=1) + 126 at async.c:80
        frame #13: 0x0022401a Mapbox GL`uv__async_io(loop=0x17e217e0, w=0x17e218bc, events=1) + 190 at async.c:156
        frame #14: 0x00236e04 Mapbox GL`uv__io_poll(loop=0x17e217e0, timeout=-1) + 2252 at kqueue.c:233
        frame #15: 0x002244da Mapbox GL`uv_run(loop=0x17e217e0, mode=UV_RUN_DEFAULT) + 130 at core.c:317
        frame #16: 0x0007884c Mapbox GL`mbgl::Map::run(this=0x18946e00) + 792 at map.cpp:254
        frame #17: 0x0007e874 Mapbox GL`mbgl::Map::start(this=0x17de1120)::$_3::operator()() const + 192 at map.cpp:163
        frame #18: 0x0007e66a Mapbox GL`void* std::__1::__thread_proxy<std::__1::tuple<mbgl::Map::start(__vp=0x17de1120)::$_3> >(void*) + 274 at memory:2602
        frame #19: 0x3a974918 libsystem_pthread.dylib`_pthread_body + 140
        frame #20: 0x3a97488a libsystem_pthread.dylib`_pthread_start + 102
    
    
    
  7. incanus commented on Mar 24, 2015

    @incanus
    Contributor

    Check on #1077. With that I am able to tap the style switcher as fast as possible many times and not get a crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions