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

Fatal Exception: std::out_of_range unordered_map::at: key not found #11788

Closed
shinma opened this issue Apr 27, 2018 · 4 comments
Closed

Fatal Exception: std::out_of_range unordered_map::at: key not found #11788

shinma opened this issue Apr 27, 2018 · 4 comments
Labels
Core The cross-platform C++ core, aka mbgl crash

Comments

@shinma
Copy link

shinma commented Apr 27, 2018

Platform: iOS 10.0 - 11.3.1
Mapbox SDK version: 4.0.0

Steps to trigger behavior

Unfortunately I don't have input parameters because it happened to few of ours users.

Expected behavior

No exception. 😄

Actual behavior

10 | libc++abi.dylib | __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 134
11 | Mapbox | std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, 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> > > >, 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, 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> > > > > > >::at(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const + 100
12 | Mapbox | mbgl::FeatureIndex::addFeature(std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > >, 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, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > > > > >&, mbgl::IndexedSubfeature const&, mbgl::GeometryCoordinates const&, mbgl::RenderedQueryOptions const&, mbgl::CanonicalTileID const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&, float, float) const + 96
13 | Mapbox | mbgl::FeatureIndex::query(std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > >, 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, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > > > > >&, mbgl::GeometryCoordinates const&, float, double, double, mbgl::RenderedQueryOptions const&, mbgl::UnwrappedTileID const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&, mbgl::CollisionIndex const&, float) const + 452
14 | Mapbox | mbgl::GeometryTile::queryRenderedFeatures(std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > >, 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, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > > > > >&, mbgl::GeometryCoordinates const&, mbgl::TransformState const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&, mbgl::RenderedQueryOptions const&, mbgl::CollisionIndex const&) + 344
15 | Mapbox | mbgl::TilePyramid::queryRenderedFeatures(mapbox::geometry::line_string<double, std::__1::vector> const&, mbgl::TransformState const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&, mbgl::RenderedQueryOptions const&, mbgl::CollisionIndex const&) const + 500
16 | Mapbox | mbgl::Renderer::Impl::queryRenderedFeatures(mapbox::geometry::line_string<double, std::__1::vector> const&, mbgl::RenderedQueryOptions const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&) const + 868
17 | Mapbox | mbgl::Renderer::Impl::queryRenderedFeatures(mapbox::geometry::line_string<double, std::__1::vector> const&, mbgl::RenderedQueryOptions const&) const + 276
18 | Mapbox | mbgl::Renderer::queryRenderedFeatures(mapbox::geometry::box<double> const&, mbgl::RenderedQueryOptions const&) const + 176
19 | Mapbox | -[MGLMapView visibleFeaturesInRect:inStyleLayersWithIdentifiers:predicate:] + 636
20 | Mapbox | -[MGLMapView visibleFeaturesInRect:inStyleLayersWithIdentifiers:] + 24
10 | libc++abi.dylib | __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 130
11 | Mapbox | std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, 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> > > >, 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, 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> > > > > > >::at(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const + 100
12 | Mapbox | mbgl::FeatureIndex::addFeature(std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > >, 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, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > > > > >&, mbgl::IndexedSubfeature const&, mbgl::GeometryCoordinates const&, mbgl::RenderedQueryOptions const&, mbgl::CanonicalTileID const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&, float, float) const + 96
13 | Mapbox | mbgl::FeatureIndex::query(std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > >, 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, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > > > > >&, mbgl::GeometryCoordinates const&, float, double, double, mbgl::RenderedQueryOptions const&, mbgl::UnwrappedTileID const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&, mbgl::CollisionIndex const&, float) const + 452
14 | Mapbox | mbgl::GeometryTile::queryRenderedFeatures(std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > >, 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, std::__1::vector<mapbox::geometry::feature<double>, std::__1::allocator<mapbox::geometry::feature<double> > > > > >&, mbgl::GeometryCoordinates const&, mbgl::TransformState const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&, mbgl::RenderedQueryOptions const&, mbgl::CollisionIndex const&) + 344
15 | Mapbox | mbgl::TilePyramid::queryRenderedFeatures(mapbox::geometry::line_string<double, std::__1::vector> const&, mbgl::TransformState const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&, mbgl::RenderedQueryOptions const&, mbgl::CollisionIndex const&) const + 500
16 | Mapbox | mbgl::Renderer::Impl::queryRenderedFeatures(mapbox::geometry::line_string<double, std::__1::vector> const&, mbgl::RenderedQueryOptions const&, std::__1::vector<mbgl::RenderLayer const*, std::__1::allocator<mbgl::RenderLayer const*> > const&) const + 868
17 | Mapbox | mbgl::Renderer::Impl::queryRenderedFeatures(mapbox::geometry::line_string<double, std::__1::vector> const&, mbgl::RenderedQueryOptions const&) const + 276
18 | Mapbox | mbgl::Renderer::queryRenderedFeatures(mapbox::geometry::box<double> const&, mbgl::RenderedQueryOptions const&) const + 176
19 | Mapbox | -[MGLMapView visibleFeaturesInRect:inStyleLayersWithIdentifiers:predicate:] + 636
20 | Mapbox | -[MGLMapView visibleFeaturesInRect:inStyleLayersWithIdentifiers:] + 24
@shinma
Copy link
Author

shinma commented Apr 27, 2018

If you can provide quick fix I can apply it and check it on TestFlight.

@friedbunny friedbunny added crash Core The cross-platform C++ core, aka mbgl labels Apr 27, 2018
@jfirebaugh
Copy link
Contributor

This is presumably throwing here:

for (const std::string& layerID : bucketLayerIDs.at(indexedFeature.bucketLeaderID)) {

@ChrisLoer, does this ring any bells? Any idea why bucketLayerIDs would not contain the bucketLeaderID we're looking for?

@ChrisLoer
Copy link
Contributor

I suspect this is already fixed in #11742, which I'm trying to port to release-boba right now. #11742 incidentally fixed the bug we just identified yesterday at #11780 (comment) (it's not a crazy coincidence that it fixed the bug: one motivation for the PR was to make this logic easier to understand). #11780 manifested as query results returning out of order, but the fundamental problem was that there was a potential window in which the committed FeatureIndex for a tile didn't match the version of the data used to create the CollisionIndex. So if that were to happen in a situation where a layer had just been removed, it could probably cause this crash: the CollisionIndex would have a pointer to a feature with that bucket name, but the corresponding FeatureIndex wouldn't be able to find the bucket name.

@ChrisLoer
Copy link
Contributor

I believe this should be fixed on release-boba by #11952, and should go out with the 4.0.2 iOS release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl crash
Projects
None yet
Development

No branches or pull requests

4 participants