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

Segfault clustering an empty feature collection — KDBush::select<>() #7622

Closed
nitrag opened this issue Jan 7, 2017 · 8 comments
Closed
Assignees
Labels
crash iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling
Milestone

Comments

@nitrag
Copy link
Contributor

nitrag commented Jan 7, 2017

Platform: iOS
Mapbox SDK version: 3.4.0-beta6

Steps to trigger behavior

var campOptions = [MGLShapeSourceOption : Any]()
campOptions[MGLShapeSourceOption.clustered] = true  //no problem with 'false'

//create empty data source
let campsiteData = MGLShapeSource(identifier: "campsite-data", shape: nil, options: campOptions)
//crashes here
Mapbox`::-[MGLShapeSource setShape:](MGLShape *):
    0x1012e43a4 <+0>:   stp    x24, x23, [sp, #-64]!
    0x1012e43a8 <+4>:   stp    x22, x21, [sp, #16]
    0x1012e43ac <+8>:   stp    x20, x19, [sp, #32]
    0x1012e43b0 <+12>:  stp    x29, x30, [sp, #48]
    0x1012e43b4 <+16>:  add    x29, sp, #48              ; =48 
    0x1012e43b8 <+20>:  sub    sp, sp, #128              ; =128 
    0x1012e43bc <+24>:  mov    x20, x0
    0x1012e43c0 <+28>:  adrp   x22, 580
    0x1012e43c4 <+32>:  ldr    x22, [x22, #2048]
    0x1012e43c8 <+36>:  ldr    x22, [x22]
    0x1012e43cc <+40>:  stur   x22, [x29, #-56]
    0x1012e43d0 <+44>:  mov    x0, x2
    0x1012e43d4 <+48>:  bl     0x1014a5770               ; symbol stub for: objc_retain
    0x1012e43d8 <+52>:  mov    x19, x0
    0x1012e43dc <+56>:  adrp   x8, 611
    0x1012e43e0 <+60>:  ldr    x1, [x8, #664]
    0x1012e43e4 <+64>:  mov    x0, x20
    0x1012e43e8 <+68>:  bl     0x1014a5740               ; symbol stub for: objc_msgSend
    0x1012e43ec <+72>:  mov    x21, x0
    0x1012e43f0 <+76>:  cbz    x19, 0x1012e4414          ; <+112> at MGLShapeSource.mm:102
    0x1012e43f4 <+80>:  adrp   x8, 611
    0x1012e43f8 <+84>:  ldr    x1, [x8, #184]
    0x1012e43fc <+88>:  mov    x8, sp
    0x1012e4400 <+92>:  mov    x0, x19
    0x1012e4404 <+96>:  bl     0x1014a5740               ; symbol stub for: objc_msgSend
    0x1012e4408 <+100>: b      0x1012e4424               ; <+128> at MGLShapeSource.mm:102
    0x1012e440c <+104>: mov    x20, x0
    0x1012e4410 <+108>: b      0x1012e4488               ; <+228> at MGLShapeSource.mm:104
    0x1012e4414 <+112>: mov    x0, sp
    0x1012e4418 <+116>: orr    w2, wzr, #0x78
    0x1012e441c <+120>: movz   w1, #0
    0x1012e4420 <+124>: bl     0x1014a6130               ; symbol stub for: memset
    0x1012e4424 <+128>: mov    x23, sp
    0x1012e4428 <+132>: mov    x1, sp
    0x1012e442c <+136>: mov    x0, x21
    0x1012e4430 <+140>: bl     0x10144ab1c               ; mbgl::style::GeoJSONSource::setGeoJSON(mapbox::util::variant<mapbox::geometry::geometry<double>, mapbox::geometry::feature<double>, mapbox::geometry::feature_collection<double, std::__1::vector> > const&)
>   0x1012e4434 <+144>: ldr    x0, [sp]   <--crash here
    0x1012e4438 <+148>: add    x1, x23, #8               ; =8 
    0x1012e443c <+152>: bl     0x1012d937c               ; mapbox::util::detail::variant_helper<mapbox::geometry::geometry<double>, mapbox::geometry::feature<double>, mapbox::geometry::feature_collection<double, std::__1::vector> >::destroy at variant.hpp:212
    0x1012e4440 <+156>: adrp   x8, 613
    0x1012e4444 <+160>: ldrsw  x8, [x8, #2656]
    0x1012e4448 <+164>: ldr    x0, [x20, x8]
    0x1012e444c <+168>: str    x19, [x20, x8]
    0x1012e4450 <+172>: bl     0x1014a5764               ; symbol stub for: objc_release
    0x1012e4454 <+176>: ldur   x8, [x29, #-56]
    0x1012e4458 <+180>: sub    x8, x22, x8
    0x1012e445c <+184>: cbnz   x8, 0x1012e4498           ; <+244> at MGLShapeSource.mm:104
    0x1012e4460 <+188>: sub    sp, x29, #48              ; =48 
    0x1012e4464 <+192>: ldp    x29, x30, [sp, #48]
    0x1012e4468 <+196>: ldp    x20, x19, [sp, #32]
    0x1012e446c <+200>: ldp    x22, x21, [sp, #16]
    0x1012e4470 <+204>: ldp    x24, x23, [sp], #64
    0x1012e4474 <+208>: ret    
    0x1012e4478 <+212>: mov    x20, x0
    0x1012e447c <+216>: ldr    x0, [sp]
    0x1012e4480 <+220>: add    x1, x23, #8               ; =8 
    0x1012e4484 <+224>: bl     0x1012d937c               ; mapbox::util::detail::variant_helper<mapbox::geometry::geometry<double>, mapbox::geometry::feature<double>, mapbox::geometry::feature_collection<double, std::__1::vector> >::destroy at variant.hpp:212
    0x1012e4488 <+228>: mov    x0, x19
    0x1012e448c <+232>: bl     0x1014a5764               ; symbol stub for: objc_release
    0x1012e4490 <+236>: mov    x0, x20
    0x1012e4494 <+240>: bl     0x1014a5eb4               ; symbol stub for: _Unwind_Resume
    0x1012e4498 <+244>: bl     0x1014a5f08               ; symbol stub for: __stack_chk_fail

Expected behavior

Actual behavior

@nitrag
Copy link
Contributor Author

nitrag commented Jan 7, 2017

In addition, and separate to the crash above, I am also getting the same exact crash signature when later appending shapes. It's hard to reproduce, it will work fine ~15 times then crash. This is a critical issue for my app.

campsiteData?.shape = try? MGLShape(data: newData, encoding: .allZeros)

I see nothing wrong with the JSON I'm appending, remember it worked many times prior.

JSON RESPONSE: {
    crs =     {
        properties =         {
            name = "EPSG:4326";
        };
        type = name;
    };
    features =     (
                {
            geometry =             {
                coordinates =                 (
                    "-88.74217299999999",
                    "30.843389"
                );
                type = Point;
            };
            properties =             {
                approved = 1;
                backcountry = yes;
                geoid = 3627627245;
                tents = yes;
                tourism = "camp_site";
            };
            type = Feature;
        },
                {
            geometry =             {
                coordinates =                 (
                    "-88.761403",
                    "30.872691"
                );
                type = Point;
            };
            properties =             {
                approved = 1;
                backcountry = yes;
                geoid = 3627629203;
                tents = yes;
                tourism = "camp_site";
            };
            type = Feature;
        },
                {
            geometry =             {
                coordinates =                 (
                    "-88.820539",
                    "32.228819"
                );
                type = Point;
            };
            properties =             {
                approved = 1;
                geoid = 3216120803;
                name = "Dunn's Falls Water Park";
                operator = "Pat Harrison Waterway District";
                phone = "+1 (601) 655-8550";
                tourism = "camp_site";
                website = "http://www.phwd.net/dunns/dunns.html";
            };
            type = Feature;
        }
    );
    type = FeatureCollection;
}

crash2:

JSON RESPONSE: {
    crs =     {
        properties =         {
            name = "EPSG:4326";
        };
        type = name;
    };
    features =     (
                {
            geometry =             {
                coordinates =                 (
                    "-79.690586",
                    "33.061083"
                );
                type = Point;
            };
            properties =             {
                approved = 1;
                geoid = 1195798996;
                name = "Halfway Creek Trail Camp";
                tourism = "camp_site";
            };
            type = Feature;
        }
    );
    type = FeatureCollection;
}

@1ec5 1ec5 added crash iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling labels Jan 7, 2017
@1ec5
Copy link
Contributor

1ec5 commented Jan 7, 2017

@nitrag, any chance you could include a symbolicated crash trace instead of a disassembly? That’ll help us make sure we’re looking at the same crash as you. Since you’re already in the debugger, selecting some lines in the Debug navigator and copy-pasting them should give us the information we need.

A couple guesses, in the meantime:

  • Perhaps there’s a regression in our handling of nil shapes in shape sources. That’s something that previously just happened to work, but maybe we need to add special handling for it.
  • In your use of MGLShape(data:encoding:), you’re passing .allZeros as the encoding. That strikes me as unusual, equivalent to passing 0 in Objective-C, whereas something like .utf8 would be expected. (This parameter works the same way as the second parameter to String(data:encoding:).) Given your use of try?, can you verify that MGLShape(data:encoding:) is returning something other than nil?

/cc @frederoni

@1ec5 1ec5 added this to the ios-v3.4.0 milestone Jan 7, 2017
@nitrag
Copy link
Contributor Author

nitrag commented Jan 7, 2017

@1ec5 Thanks for the weekend reply.

I'm glad you brought up .allZeros, I thought it was a bit odd but it's the only option available to me. If I try to use: .utf8 I get an error: Type 'UInt' has no member 'utf8'

I added a let statement on the try? but still crashes. It wasn't ever nil.

Not sure how to work stacktraces in simulator...seems like it should be easier than this.... I'm researching how to do this, any tips would be helpful. Is this perhaps what you were looking for?

#0	0x0000000101457290 in mbgl::style::GeoJSONSource::Impl::_setGeoJSON(mapbox::util::variant<mapbox::geometry::geometry<double>, mapbox::geometry::feature<double>, mapbox::geometry::feature_collection<double, std::__1::vector> > const&) ()
#1	0x00000001012f0434 in ::-[MGLShapeSource setShape:](MGLShape *) at /Users/boundsj/mapbox-gl-native/platform/darwin/src/MGLShapeSource.mm:102
#2	0x0000000100089cac in MapViewController.(fetchCampsites() -> ()).(closure #1).(closure #1) at /Users/ryan/Documents/XCode/offroad2/offroad2/MapViewController.swift:835

The closure is where it crashes trying to set the shape.

@nitrag
Copy link
Contributor Author

nitrag commented Jan 7, 2017

.utf8 is of type String.Encoding and it's expecting UInt

image

@1ec5
Copy link
Contributor

1ec5 commented Jan 8, 2017

The method is declared in Objective-C with the parameter’s type as NSStringEncoding. Swift is unable to bridge the use of NSStringEncoding, which is unfortunately defined as a typedef to NSUInteger instead of an enumeration. NSString(data:encoding:) (in Foundation) suffers from the same problem, but String(data:encoding:) (in the Swift standard library) does not. It looks like I end up having to use String.Encoding.utf8.rawValue.

Ideally, we’d mark the method with NS_REFINED_FOR_SWIFT and add a Swift file that refines the method’s signature. Much as I’d love for us to aggressively refine the API for Swift (#5178), refining it beyond renaming methods isn’t straightforward because we also distribute the SDK as a static framework. As a stopgap, we should add an example to the method’s documentation that uses String.Encoding.utf8.rawValue.

@1ec5
Copy link
Contributor

1ec5 commented Jan 8, 2017

I’ve added an example to the documentation in #7627.

Meanwhile, I can reproduce the crash. As you pointed out, the crash only occurs when specifying a clustering option:

MGLShapeSource(identifier: "foo", shape: nil, options: [.clustered: true])

The nil MGLShape gets converted into an mapbox::geometry::null_value_t. The crash is way down in kdbush.hpp; we go down this code path if and only if clustering is turned on:

Thread 1Queue : com.apple.main-thread (serial)
#0	0x00000001055dd7da in void kdbush::KDBush<mapbox::supercluster::Cluster, unsigned int>::select<(unsigned char)0>(unsigned int, unsigned int, unsigned int) at /Users/mxn/hub/mapbox-gl-native-2/mason_packages/headers/kdbush/0.1.1/include/kdbush.hpp:176
#1	0x00000001055dc131 in kdbush::KDBush<mapbox::supercluster::Cluster, unsigned int>::sortKD(unsigned int, unsigned int, unsigned char) at /Users/mxn/hub/mapbox-gl-native-2/mason_packages/headers/kdbush/0.1.1/include/kdbush.hpp:154
#2	0x00000001055dbf5c in void kdbush::KDBush<mapbox::supercluster::Cluster, unsigned int>::fill<std::__1::__wrap_iter<mapbox::supercluster::Cluster const*> >(std::__1::__wrap_iter<mapbox::supercluster::Cluster const*> const&, std::__1::__wrap_iter<mapbox::supercluster::Cluster const*> const&) at /Users/mxn/hub/mapbox-gl-native-2/mason_packages/headers/kdbush/0.1.1/include/kdbush.hpp:63
#3	0x00000001055da958 in kdbush::KDBush<mapbox::supercluster::Cluster, unsigned int>::fill(std::__1::vector<mapbox::supercluster::Cluster, std::__1::allocator<mapbox::supercluster::Cluster> > const&) at /Users/mxn/hub/mapbox-gl-native-2/mason_packages/headers/kdbush/0.1.1/include/kdbush.hpp:46
#4	0x00000001055da5de in mapbox::supercluster::Supercluster::Zoom::Zoom(mapbox::geometry::feature_collection<double, std::__1::vector> const&) at /Users/mxn/hub/mapbox-gl-native-2/mason_packages/headers/supercluster/0.2.0/include/supercluster.hpp:167
#5	0x00000001055da03d in mapbox::supercluster::Supercluster::Zoom::Zoom(mapbox::geometry::feature_collection<double, std::__1::vector> const&) at /Users/mxn/hub/mapbox-gl-native-2/mason_packages/headers/supercluster/0.2.0/include/supercluster.hpp:159
#6	0x00000001055d8f9f in std::__1::pair<unsigned char const, mapbox::supercluster::Supercluster::Zoom>::pair<int, mapbox::geometry::feature_collection<double, std::__1::vector> const&, void>(int&&, mapbox::geometry::feature_collection<double, std::__1::vector> const&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/utility:318
#7	0x00000001055d8f7a in std::__1::pair<unsigned char const, mapbox::supercluster::Supercluster::Zoom>::pair<int, mapbox::geometry::feature_collection<double, std::__1::vector> const&, void>(int&&, mapbox::geometry::feature_collection<double, std::__1::vector> const&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/utility:319
#8	0x00000001055d8f66 in void std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*> >::construct<std::__1::pair<unsigned char const, mapbox::supercluster::Supercluster::Zoom>, int, mapbox::geometry::feature_collection<double, std::__1::vector> const&>(std::__1::pair<unsigned char const, mapbox::supercluster::Supercluster::Zoom>*, int&&, mapbox::geometry::feature_collection<double, std::__1::vector> const&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1740
#9	0x00000001055d8f39 in void std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*> > >::__construct<std::__1::pair<unsigned char const, mapbox::supercluster::Supercluster::Zoom>, int, mapbox::geometry::feature_collection<double, std::__1::vector> const&>(std::__1::integral_constant<bool, true>, std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*> >&, std::__1::pair<unsigned char const, mapbox::supercluster::Supercluster::Zoom>*, int&&, mapbox::geometry::feature_collection<double, std::__1::vector> const&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1656
#10	0x00000001055d8ef9 in void std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*> > >::construct<std::__1::pair<unsigned char const, mapbox::supercluster::Supercluster::Zoom>, int, mapbox::geometry::feature_collection<double, std::__1::vector> const&>(std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*> >&, std::__1::pair<unsigned char const, mapbox::supercluster::Supercluster::Zoom>*, int&&, mapbox::geometry::feature_collection<double, std::__1::vector> const&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1502
#11	0x00000001055d8eb6 in std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*>, std::__1::__hash_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*> > > > std::__1::__hash_table<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, std::__1::__unordered_map_hasher<unsigned char, std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, std::__1::hash<unsigned char>, true>, std::__1::__unordered_map_equal<unsigned char, std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, std::__1::equal_to<unsigned char>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom> > >::__construct_node<int, mapbox::geometry::feature_collection<double, std::__1::vector> const&>(int&&, mapbox::geometry::feature_collection<double, std::__1::vector> const&&&) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:2259
#12	0x00000001055d7cfa in std::__1::pair<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*>*>, bool> std::__1::__hash_table<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, std::__1::__unordered_map_hasher<unsigned char, std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, std::__1::hash<unsigned char>, true>, std::__1::__unordered_map_equal<unsigned char, std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, std::__1::equal_to<unsigned char>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom> > >::__emplace_unique_impl<int, mapbox::geometry::feature_collection<double, std::__1::vector> const&>(int&&, mapbox::geometry::feature_collection<double, std::__1::vector> const&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:2046
#13	0x00000001055d7cb4 in std::__1::pair<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*>*>, bool> std::__1::__hash_table<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, std::__1::__unordered_map_hasher<unsigned char, std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, std::__1::hash<unsigned char>, true>, std::__1::__unordered_map_equal<unsigned char, std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, std::__1::equal_to<unsigned char>, true>, std::__1::allocator<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom> > >::__emplace_unique<int, mapbox::geometry::feature_collection<double, std::__1::vector> const&>(int&&, mapbox::geometry::feature_collection<double, std::__1::vector> const&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:1078
#14	0x00000001055d7c7c in std::__1::pair<std::__1::__hash_map_iterator<std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<unsigned char, mapbox::supercluster::Supercluster::Zoom>, void*>*> >, bool> std::__1::unordered_map<unsigned char, mapbox::supercluster::Supercluster::Zoom, std::__1::hash<unsigned char>, std::__1::equal_to<unsigned char>, std::__1::allocator<std::__1::pair<unsigned char const, mapbox::supercluster::Supercluster::Zoom> > >::emplace<int, mapbox::geometry::feature_collection<double, std::__1::vector> const&>(int&&, mapbox::geometry::feature_collection<double, std::__1::vector> const&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:916
#15	0x00000001055d7c44 in mapbox::supercluster::Supercluster::Supercluster(mapbox::geometry::feature_collection<double, std::__1::vector> const&, mapbox::supercluster::Options) at /Users/mxn/hub/mapbox-gl-native-2/mason_packages/headers/supercluster/0.2.0/include/supercluster.hpp:96
#16	0x00000001055d7908 in mapbox::supercluster::Supercluster::Supercluster(mapbox::geometry::feature_collection<double, std::__1::vector> const&, mapbox::supercluster::Options) at /Users/mxn/hub/mapbox-gl-native-2/mason_packages/headers/supercluster/0.2.0/include/supercluster.hpp:90
#17	0x0000000105593471 in std::__1::__unique_if<mapbox::supercluster::Supercluster>::__unique_single std::__1::make_unique<mapbox::supercluster::Supercluster, mapbox::geometry::feature_collection<double, std::__1::vector> const&, mapbox::supercluster::Options&>(mapbox::geometry::feature_collection<double, std::__1::vector> const&&&, mapbox::supercluster::Options&&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3141
#18	0x00000001055933d3 in mbgl::style::GeoJSONSource::Impl::_setGeoJSON(mapbox::util::variant<mapbox::geometry::geometry<double>, mapbox::geometry::feature<double>, mapbox::geometry::feature_collection<double, std::__1::vector> > const&) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/style/sources/geojson_source_impl.cpp:82
#19	0x0000000105592fc3 in mbgl::style::GeoJSONSource::Impl::setGeoJSON(mapbox::util::variant<mapbox::geometry::geometry<double>, mapbox::geometry::feature<double>, mapbox::geometry::feature_collection<double, std::__1::vector> > const&) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/style/sources/geojson_source_impl.cpp:57
#20	0x00000001055920c1 in mbgl::style::GeoJSONSource::setGeoJSON(mapbox::util::variant<mapbox::geometry::geometry<double>, mapbox::geometry::feature<double>, mapbox::geometry::feature_collection<double, std::__1::vector> > const&) at /Users/mxn/hub/mapbox-gl-native-2/src/mbgl/style/sources/geojson_source.cpp:18
#21	0x00000001050eff40 in ::-[MGLShapeSource setShape:](MGLShape *) at /Users/mxn/hub/mapbox-gl-native-2/platform/darwin/src/MGLShapeSource.mm:103
#22	0x00000001050ee8b4 in ::-[MGLShapeSource initWithIdentifier:shape:options:](NSString *, MGLShape *, NSDictionary *) at /Users/mxn/hub/mapbox-gl-native-2/platform/darwin/src/MGLShapeSource.mm:54
#23	0x0000000103ac3076 in @nonobjc MGLShapeSource.init(identifier : String, shape : MGLShape?, options : [MGLShapeSourceOption : Any]?) -> MGLShapeSource ()
#24	0x0000000103abc1d1 in MGLShapeSource.__allocating_init(identifier : String, shape : MGLShape?, options : [MGLShapeSourceOption : Any]?) -> MGLShapeSource ()
Printing description of k:
(const unsigned int) k = 2147483647
Printing description of left:
(unsigned int) left = 0
Printing description of right:
(unsigned int) right = 4294967295
Printing description of this->points:
(std::__1::vector<std::__1::pair<double, double>, std::__1::allocator<std::__1::pair<double, double> > >) points = size=0 {}

The same crash occurs when creating the shape source with a feature collection containing no features.

/cc @mourner

@1ec5 1ec5 changed the title iOS MGLShapeSource - Clustering immediately crashes Segfault clustering a null geometry — KDBush::select<>() Jan 8, 2017
@1ec5 1ec5 changed the title Segfault clustering a null geometry — KDBush::select<>() Segfault clustering an empty feature collection — KDBush::select<>() Jan 8, 2017
@boundsj boundsj assigned boundsj, 1ec5 and mourner and unassigned boundsj Jan 8, 2017
@boundsj
Copy link
Contributor

boundsj commented Jan 9, 2017

Fixed in #7633 on the release-ios-v3.4.0 branch.

@boundsj boundsj closed this as completed Jan 9, 2017
1ec5 pushed a commit that referenced this issue Jan 11, 2017
1ec5 pushed a commit that referenced this issue Jan 12, 2017
1ec5 added a commit that referenced this issue Jan 12, 2017
#7687)

* Add Clarification for modifying ShapeCollections

Spinoff task from #7622

* update wording for both get/set, remove whitespace
@1ec5
Copy link
Contributor

1ec5 commented Jan 16, 2017

mapbox/supercluster.hpp#5 and mapbox/supercluster.hpp#6 track the underlying issues behind this crash.

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 macOS Mapbox Maps SDK for macOS runtime styling
Projects
None yet
Development

No branches or pull requests

4 participants