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

EXC_BAD_ACCESS on access of ref to MGLStyleLayer in previous style #13957

Closed
johnkassebaum opened this issue Feb 20, 2019 · 4 comments
Closed
Labels
archived Archived because of inactivity crash iOS Mapbox Maps SDK for iOS

Comments

@johnkassebaum
Copy link

johnkassebaum commented Feb 20, 2019

In our Mapbox iOS SDK use case, we get new versions of the stylesheet pushed to the app, which are then stored as files, so styleURL is set to a file URL. Resetting styleURL in this way obviously reloads style and so removes any sources and style layers that I had added for annotations not defined in the stylesheet, and so those sources and style layers need to be recreated. (Yes, when the map reloads the style there is a blip, but it won't happen often at all.)

To make recreating the additional annotations easy, I keep a reference to the added sources and style layers in some arrays and dictionaries. I know I can't reuse the sources and style layers in the new style, but their properties can be copied (e.g., shape) rather than reconstructed. But unfortunately, after the style reloads, accessing the annotation style layers results in a crash. Accessing the sources is OK.

For some annotations, like points, the sources are all MGLShapeSources, and I simply do newShapeSource.shape = oldShapeSource.shape.

Some annotations, tho, track feature IDs in the style layer predicate "id == ". But like I said, trying to access any style layer that was inserted in the previous style results in a crash.

Steps to reproduce

  1. Create a source and style layer and add to style.
  2. Keep a reference to source and to style layer
  3. set a new styleURL
  4. in mapView(_:didFinishLoading:) style, access the style layer by your stored reference -- causes EXC_BAD_ACCESS. At a breakpoint just before the access, po styleLayer in console gives:
Victor Vector(19677,0x116d4e5c0) malloc: can't allocate region
*** mach_vm_map(size=14085975404842041344) failed (error code=3)
Victor Vector(19677,0x116d4e5c0) malloc: *** set a breakpoint in malloc_error_break to debug
expression produced error: error: Execution was interrupted, reason: internal c++ exception breakpoint(-4)..

Full stack trace below.

Expected behavior

The style layer should still exist and be accessible since it is stored in a persistent dictionary or array.

Actual behavior

Accessing the style layer results in a crash:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
  * frame #0: 0x000000010fde4116 Mapbox`std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mapbox::feature::value> > >::unordered_map(std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mapbox::feature::value> > > const&) [inlined] std::__1::__hash_table<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value>, std::__1::__unordered_map_hasher<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value>, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::__unordered_map_equal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value> > >::__hash_table(this=0x000060000073f0c0, __u=0x493649533f800000) at __hash_table:1428 [opt]
    frame #1: 0x000000010fde4107 Mapbox`std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mapbox::feature::value> > >::unordered_map(std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mapbox::feature::value> > > const&) [inlined] std::__1::__hash_table<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value>, std::__1::__unordered_map_hasher<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value>, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::__unordered_map_equal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value> > >::__hash_table(this=0x000060000073f0c0, __u=0x493649533f800000) at __hash_table:1429 [opt]
    frame #2: 0x000000010fde4107 Mapbox`std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mapbox::feature::value> > >::unordered_map(this=0x000060000073f0c0 size=0, __u=size=0) at unordered_map:1253 [opt]
    frame #3: 0x000000010fde4b8f Mapbox`mapbox::util::recursive_wrapper<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mapbox::feature::value> > > >::recursive_wrapper(mapbox::util::recursive_wrapper<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mapbox::feature::value> > > > const&) [inlined] std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mapbox::feature::value> > >::unordered_map(this=<unavailable>, __u=<unavailable>) at unordered_map:1254 [opt]
    frame #4: 0x000000010fde4b87 Mapbox`mapbox::util::recursive_wrapper<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, mapbox::feature::value, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, mapbox::feature::value> > > >::recursive_wrapper(this=0x00007ffee5fa3240, operand=0x00007f88d1130168) at recursive_wrapper.hpp:50 [opt]
    frame #5: 0x000000010fe9d422 Mapbox`::-[MGLFillStyleLayer predicate]() [inlined] mapbox::feature::value::value((null)=<unavailable>) at feature.hpp:36 [opt]
    frame #6: 0x000000010fe9d415 Mapbox`::-[MGLFillStyleLayer predicate]() [inlined] mapbox::feature::value::value((null)=<unavailable>) at feature.hpp:36 [opt]
    frame #7: 0x000000010fe9d415 Mapbox`::-[MGLFillStyleLayer predicate]() [inlined] std::experimental::fundamentals_v1::__optional_storage<mapbox::feature::value, false>::__optional_storage(__x=<unavailable>) at optional:218 [opt]
    frame #8: 0x000000010fe9d408 Mapbox`::-[MGLFillStyleLayer predicate]() [inlined] std::experimental::fundamentals_v1::optional<mapbox::feature::value>::optional((null)=<unavailable>) at optional:319 [opt]
    frame #9: 0x000000010fe9d408 Mapbox`::-[MGLFillStyleLayer predicate]() [inlined] std::experimental::fundamentals_v1::optional<mapbox::feature::value>::optional((null)=<unavailable>) at optional:319 [opt]
    frame #10: 0x000000010fe9d408 Mapbox`::-[MGLFillStyleLayer predicate]() [inlined] mbgl::style::Filter::Filter((null)=<unavailable>) at filter.hpp:15 [opt]
    frame #11: 0x000000010fe9d3e4 Mapbox`::-[MGLFillStyleLayer predicate]() [inlined] mbgl::style::Filter::Filter((null)=<unavailable>) at filter.hpp:15 [opt]
    frame #12: 0x000000010fe9d3e4 Mapbox`::-[MGLFillStyleLayer predicate](self=0x00006000007a7ea0, _cmd=<unavailable>) at MGLFillStyleLayer.mm:81 [opt]
    frame #13: 0x000000010fdf2263 Mapbox`-[MGLVectorStyleLayer description](self=0x00006000007a7ea0, _cmd=<unavailable>) at MGLVectorStyleLayer.m:21 [opt]
    frame #14: 0x0000000113e9d444 libswiftFoundation.dylib`merged protocol witness for Swift.CustomStringConvertible.description.getter : Swift.String in conformance __C.NSObject : Swift.CustomStringConvertible in Foundation + 36
    frame #15: 0x0000000113e9d410 libswiftFoundation.dylib`protocol witness for Swift.CustomDebugStringConvertible.debugDescription.getter : Swift.String in conformance __C.NSObject : Swift.CustomDebugStringConvertible in Foundation + 16
    frame #16: 0x00000001137dd85d libswiftCore.dylib`Swift._debugPrint_unlocked<A, B where B: Swift.TextOutputStream>(A, inout B) -> () + 381
    frame #17: 0x0000000113963715 libswiftCore.dylib`function signature specialization <Arg[1] = Exploded, Arg[2] = Exploded> of generic specialization <Swift.String> of Swift._debugPrint<A where A: Swift.TextOutputStream>(_: Swift.Array<Any>, separator: Swift.String, terminator: Swift.String, to: inout A) -> () + 3029
    frame #18: 0x0000000113769dc6 libswiftCore.dylib`Swift.Array.debugDescription.getter : Swift.String + 422
    frame #19: 0x000000011376a084 libswiftCore.dylib`protocol witness for Swift.CustomDebugStringConvertible.debugDescription.getter : Swift.String in conformance Swift.Array<A> : Swift.CustomDebugStringConvertible in Swift + 20
    frame #20: 0x00000001137dd85d libswiftCore.dylib`Swift._debugPrint_unlocked<A, B where B: Swift.TextOutputStream>(A, inout B) -> () + 381
    frame #21: 0x0000000113963715 libswiftCore.dylib`function signature specialization <Arg[1] = Exploded, Arg[2] = Exploded> of generic specialization <Swift.String> of Swift._debugPrint<A where A: Swift.TextOutputStream>(_: Swift.Array<Any>, separator: Swift.String, terminator: Swift.String, to: inout A) -> () + 3029
    frame #22: 0x00000001137c548a libswiftCore.dylib`Swift.Dictionary.description.getter : Swift.String + 1162
    frame #23: 0x00000001137c641d libswiftCore.dylib`merged protocol witness for Swift.CustomStringConvertible.description.getter : Swift.String in conformance Swift.Dictionary<A, B>.Keys : Swift.CustomStringConvertible in Swift + 29
    frame #24: 0x00000001137c63d0 libswiftCore.dylib`protocol witness for Swift.CustomStringConvertible.description.getter : Swift.String in conformance Swift.Dictionary<A, B> : Swift.CustomStringConvertible in Swift + 16
    frame #25: 0x0000000113884cc3 libswiftCore.dylib`Swift._toStringReadOnlyPrintable<A where A: Swift.CustomStringConvertible>(A) -> Swift.String + 19
    frame #26: 0x00000001138e19a3 libswiftCore.dylib`merged Swift.String.init<A where A: Swift.CustomStringConvertible>(stringInterpolationSegment: A) -> Swift.String + 19
    frame #27: 0x000000011378aab0 libswiftCore.dylib`Swift.String.init<A where A: Swift.CustomStringConvertible>(stringInterpolationSegment: A) -> Swift.String + 16
    frame #28: 0x0000000109db8711 Victor Vector`MapboxMap.mapView(mapView=0x00007f88cb0f6400, style=0x00006000015b79c0, self=0x00007f88cb0f6400) at MapboxMap.swift:479
    frame #29: 0x0000000109dc2081 Victor Vector`@objc MapboxMap.mapView(_:didFinishLoading:) at <compiler-generated>:0
    frame #30: 0x000000010fe5705a Mapbox`::-[MGLMapView didFinishLoadingStyle](self=0x00007f88cb0f6400, _cmd=<unavailable>) at MGLMapView.mm:6073 [opt]
    frame #31: 0x000000010fe618f1 Mapbox`MBGLView::onDidFinishLoadingStyle(this=<unavailable>) at MGLMapView.mm:6629 [opt]
    frame #32: 0x000000010ff0dd4a Mapbox`mbgl::Map::Impl::onStyleLoaded(this=0x00007f88cc07b760) at map.cpp:787 [opt]
    frame #33: 0x000000011006c94f Mapbox`mbgl::style::Style::Impl::parse(this=<unavailable>, json_=<unavailable>) at style_impl.cpp:118 [opt]
    frame #34: 0x000000011006e596 Mapbox`std::__1::__function::__func<mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0, std::__1::allocator<mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>, void (mbgl::Response)>::operator()(mbgl::Response&&) [inlined] mbgl::style::Style::Impl::loadURL(this=<unavailable>, res=Response @ 0x00007ffee5fa4db8)::$_0::operator()(mbgl::Response) const at style_impl.cpp:71 [opt]
    frame #35: 0x000000011006e559 Mapbox`std::__1::__function::__func<mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0, std::__1::allocator<mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>, void (mbgl::Response)>::operator()(mbgl::Response&&) [inlined] decltype(__f=<unavailable>, __args=<unavailable>)::$_0&>(fp)(std::__1::forward<mbgl::Response>(fp0))) std::__1::__invoke<mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0&, mbgl::Response>(mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0&&&, mbgl::Response&&) at type_traits:4428 [opt]
    frame #36: 0x000000011006e550 Mapbox`std::__1::__function::__func<mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0, std::__1::allocator<mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>, void (mbgl::Response)>::operator()(mbgl::Response&&) [inlined] void std::__1::__invoke_void_return_wrapper<void>::__call<mbgl::style::Style::Impl::loadURL(__args=<unavailable>, __args=<unavailable>)::$_0&, mbgl::Response>(mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0&&&, mbgl::Response&&) at __functional_base:349 [opt]
    frame #37: 0x000000011006e550 Mapbox`std::__1::__function::__func<mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0, std::__1::allocator<mbgl::style::Style::Impl::loadURL(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>, void (mbgl::Response)>::operator(this=<unavailable>, __arg=<unavailable>)(mbgl::Response&&) at functional:1562 [opt]
    frame #38: 0x00000001100c5d5f Mapbox`mbgl::FileSourceRequest::setResponse(this=<unavailable>, response=<unavailable>) at file_source_request.cpp:30 [opt]
    frame #39: 0x000000010fec10c7 Mapbox`mbgl::Mailbox::maybeReceive(std::__1::weak_ptr<mbgl::Mailbox>) [inlined] mbgl::Mailbox::receive(this=0x00007f88cc157b38) at mailbox.cpp:85 [opt]
    frame #40: 0x000000010fec0fe8 Mapbox`mbgl::Mailbox::maybeReceive(mailbox=<unavailable>) at mailbox.cpp:94 [opt]
    frame #41: 0x00000001100b8bfd Mapbox`mbgl::WorkTaskImpl<mbgl::util::RunLoop::schedule(std::__1::weak_ptr<mbgl::Mailbox>)::'lambda'(), std::__1::tuple<> >::operator()() [inlined] mbgl::util::RunLoop::schedule(this=<unavailable>)::'lambda'()::operator()() const at run_loop.hpp:78 [opt]
    frame #42: 0x00000001100b8bda Mapbox`mbgl::WorkTaskImpl<mbgl::util::RunLoop::schedule(std::__1::weak_ptr<mbgl::Mailbox>)::'lambda'(), std::__1::tuple<> >::operator()() [inlined] void mbgl::WorkTaskImpl<mbgl::util::RunLoop::schedule(std::__1::weak_ptr<mbgl::Mailbox>)::'lambda'(), std::__1::tuple<> >::invoke<>(this=<unavailable>) at work_task_impl.hpp:43 [opt]
    frame #43: 0x00000001100b8bda Mapbox`mbgl::WorkTaskImpl<mbgl::util::RunLoop::schedule(std::__1::weak_ptr<mbgl::Mailbox>)::'lambda'(), std::__1::tuple<> >::operator(this=<unavailable>)() at work_task_impl.hpp:23 [opt]
    frame #44: 0x00000001100b8fe3 Mapbox`mbgl::util::RunLoop::process(this=0x0000000110204030) at run_loop.hpp:117 [opt]
    frame #45: 0x00000001119ae721 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #46: 0x00000001119adf93 CoreFoundation`__CFRunLoopDoSources0 + 243
    frame #47: 0x00000001119a863f CoreFoundation`__CFRunLoopRun + 1263
    frame #48: 0x00000001119a7e11 CoreFoundation`CFRunLoopRunSpecific + 625
    frame #49: 0x000000011681d1dd GraphicsServices`GSEventRunModal + 62
    frame #50: 0x000000011d17281d UIKitCore`UIApplicationMain + 140
    frame #51: 0x000000010a2ee5a7 Victor Vector`main at AppDelegate.swift:15
    frame #52: 0x0000000114462575 libdyld.dylib`start + 1

Configuration

Mapbox SDK versions: 4.8.0
iOS/macOS versions: 12.1
Device/simulator models: 12.1
Xcode version: 10.1

@fabian-guerra fabian-guerra added iOS Mapbox Maps SDK for iOS crash labels Feb 21, 2019
@stale stale bot added the archived Archived because of inactivity label Aug 21, 2019
@stale
Copy link

stale bot commented Aug 21, 2019

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Aug 21, 2019
@julianrex
Copy link
Contributor

Not stale, bot.
Sounds like a similar issue as #15333.

@julianrex
Copy link
Contributor

/cc @pozdnyakov @alexshalamov

@julianrex julianrex reopened this Aug 21, 2019
@stale stale bot removed the archived Archived because of inactivity label Aug 21, 2019
@stale stale bot added the archived Archived because of inactivity label Feb 17, 2020
@stale
Copy link

stale bot commented Feb 17, 2020

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Feb 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived Archived because of inactivity crash iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

3 participants