maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.07k stars 317 forks source link

SymbolLayerFactory::createLayout noexcept but can throw, unhandled exception #574

Closed mwilsnd closed 3 months ago

mwilsnd commented 1 year ago

Describe the bug Observed while investigating a report on tileserver-gl. When creating a new symbol layer layout, a SymbolFeature constructor may throw during the call to getGeometries. This exception is uncaught up to the symbol layer factory and as createLayout is noexcept, the program simply terminates.

To Reproduce Steps to reproduce the behavior:

  1. Go to the tileserver-gl issue and follow the steps to reproduce.

Expected behavior The library should handle this exception gracefully without terminating.

Screenshots N/A

Platform information (please complete the following information):

Additional context

terminate called after throwing an instance of 'std::runtime_error'
  what():  paths outside valid range of coordinate_type

Call stack:

mbgl.node!mapbox::vector_tile::feature::getGeometries<mbgl::GeometryCollection>(const mapbox::vector_tile::feature * const this, float scale) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\vendor\vector-tile\include\mapbox\vector_tile.hpp:310)
mbgl.node!mbgl::VectorTileFeature::getGeometries(const mbgl::VectorTileFeature * const this) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\tile\vector_tile_data.cpp:43)
mbgl.node!mbgl::SymbolFeature::SymbolFeature(mbgl::SymbolFeature * const this, std::unique_ptr<mbgl::GeometryTileFeature, std::default_delete<mbgl::GeometryTileFeature> > feature_) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\layout\symbol_feature.hpp:17)
mbgl.node!mbgl::SymbolLayout::SymbolLayout(mbgl::SymbolLayout * const this, const mbgl::BucketParameters & parameters, const std::vector<mbgl::Immutable<mbgl::style::LayerProperties>, std::allocator<mbgl::Immutable<mbgl::style::LayerProperties> > > & layers, std::unique_ptr<mbgl::GeometryTileLayer, std::default_delete<mbgl::GeometryTileLayer> > sourceLayer_, const mbgl::LayoutParameters & layoutParameters) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\layout\symbol_layout.cpp:140)
mbgl.node!std::make_unique<mbgl::SymbolLayout, mbgl::BucketParameters const&, std::vector<mbgl::Immutable<mbgl::style::LayerProperties>, std::allocator<mbgl::Immutable<mbgl::style::LayerProperties> > > const&, std::unique_ptr<mbgl::GeometryTileLayer, std::default_delete<mbgl::GeometryTileLayer> >, mbgl::LayoutParameters const&>() (\usr\include\c++\10\bits\unique_ptr.h:962)
mbgl.node!mbgl::SymbolLayerFactory::createLayout(mbgl::SymbolLayerFactory * const this, const mbgl::LayoutParameters & parameters, std::unique_ptr<mbgl::GeometryTileLayer, std::default_delete<mbgl::GeometryTileLayer> > tileLayer, const std::vector<mbgl::Immutable<mbgl::style::LayerProperties>, std::allocator<mbgl::Immutable<mbgl::style::LayerProperties> > > & group) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\layermanager\symbol_layer_factory.cpp:25)
mbgl.node!mbgl::LayerManager::createLayout(mbgl::LayerManager * const this, const mbgl::LayoutParameters & parameters, std::unique_ptr<mbgl::GeometryTileLayer, std::default_delete<mbgl::GeometryTileLayer> > tileLayer, const std::vector<mbgl::Immutable<mbgl::style::LayerProperties>, std::allocator<mbgl::Immutable<mbgl::style::LayerProperties> > > & layers) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\layermanager\layer_manager.cpp:47)
mbgl.node!mbgl::GeometryTileWorker::parse(mbgl::GeometryTileWorker * const this) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\tile\geometry_tile_worker.cpp:390)
mbgl.node!mbgl::GeometryTileWorker::setData(mbgl::GeometryTileWorker * const this, std::unique_ptr<mbgl::GeometryTileData const, std::default_delete<mbgl::GeometryTileData const> > data_, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > availableImages_, uint64_t correlationID_) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\tile\geometry_tile_worker.cpp:129)
mbgl.node!mbgl::MessageImpl<mbgl::GeometryTileWorker, void (mbgl::GeometryTileWorker::*)(std::unique_ptr<mbgl::GeometryTileData const, std::default_delete<mbgl::GeometryTileData const> >, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, unsigned long), std::tuple<std::unique_ptr<mbgl::GeometryTileData const, std::default_delete<mbgl::GeometryTileData const> >, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, unsigned long> >::invoke<0ul, 1ul, 2ul>(mbgl::MessageImpl<mbgl::GeometryTileWorker, void (mbgl::GeometryTileWorker::*)(std::unique_ptr<mbgl::GeometryTileData const, std::default_delete<mbgl::GeometryTileData const> >, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, unsigned long), std::tuple<std::unique_ptr<mbgl::GeometryTileData const, std::default_delete<mbgl::GeometryTileData const> >, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, unsigned long> > * const this) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\include\mbgl\actor\message.hpp:34)
mbgl.node!mbgl::MessageImpl<mbgl::GeometryTileWorker, void (mbgl::GeometryTileWorker::*)(std::unique_ptr<mbgl::GeometryTileData const, std::default_delete<mbgl::GeometryTileData const> >, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, unsigned long), std::tuple<std::unique_ptr<mbgl::GeometryTileData const, std::default_delete<mbgl::GeometryTileData const> >, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, unsigned long> >::operator()(mbgl::MessageImpl<mbgl::GeometryTileWorker, void (mbgl::GeometryTileWorker::*)(std::unique_ptr<mbgl::GeometryTileData const, std::default_delete<mbgl::GeometryTileData const> >, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, unsigned long), std::tuple<std::unique_ptr<mbgl::GeometryTileData const, std::default_delete<mbgl::GeometryTileData const> >, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, unsigned long> > * const this) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\include\mbgl\actor\message.hpp:29)
mbgl.node!mbgl::Mailbox::receive(mbgl::Mailbox * const this) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\actor\mailbox.cpp:86)
mbgl.node!mbgl::Mailbox::maybeReceive(const std::weak_ptr<mbgl::Mailbox> & mailbox) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\actor\mailbox.cpp:96)
mbgl.node!operator()(const struct {...} * const __closure) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\actor\mailbox.cpp:102)
mbgl.node!std::__invoke_impl<void, mbgl::Mailbox::makeClosure(std::weak_ptr<mbgl::Mailbox>)::<lambda()>&>(std::__invoke_other, struct {...} &)(struct {...} & __f) (\usr\include\c++\10\bits\invoke.h:60)
mbgl.node!std::__invoke_r<void, mbgl::Mailbox::makeClosure(std::weak_ptr<mbgl::Mailbox>)::<lambda()>&>(struct {...} &)(struct {...} & __fn) (\usr\include\c++\10\bits\invoke.h:110)
mbgl.node!std::_Function_handler<void(), mbgl::Mailbox::makeClosure(std::weak_ptr<mbgl::Mailbox>)::<lambda()> >::_M_invoke(const std::_Any_data &)(const std::_Any_data & __functor) (\usr\include\c++\10\bits\std_function.h:291)
mbgl.node!std::function<void ()>::operator()() const(const std::function<void()> * const this) (\usr\include\c++\10\bits\std_function.h:622)
mbgl.node!operator()(const struct {...} * const __closure) (\home\mwilsnd\git\tileserver-gl\node_modules\@maplibre\maplibre-gl-native\src\mbgl\util\thread_pool.cpp:44)
mbgl.node!std::__invoke_impl<void, mbgl::ThreadedSchedulerBase::makeSchedulerThread(size_t)::<lambda()> >(std::__invoke_other, struct {...} &&)(struct {...} && __f) (\usr\include\c++\10\bits\invoke.h:60)
mbgl.node!std::__invoke<mbgl::ThreadedSchedulerBase::makeSchedulerThread(size_t)::<lambda()> >(struct {...} &&)(struct {...} && __fn) (\usr\include\c++\10\bits\invoke.h:95)
mbgl.node!std::thread::_Invoker<std::tuple<mbgl::ThreadedSchedulerBase::makeSchedulerThread(size_t)::<lambda()> > >::_M_invoke<0>(std::_Index_tuple<0>)(std::thread::_Invoker<std::tuple<mbgl::ThreadedSchedulerBase::makeSchedulerThread(size_t)::<lambda()> > > * const this) (\usr\include\c++\10\thread:264)
mbgl.node!std::thread::_Invoker<std::tuple<mbgl::ThreadedSchedulerBase::makeSchedulerThread(size_t)::<lambda()> > >::operator()(void)(std::thread::_Invoker<std::tuple<mbgl::ThreadedSchedulerBase::makeSchedulerThread(size_t)::<lambda()> > > * const this) (\usr\include\c++\10\thread:271)
mbgl.node!std::thread::_State_impl<std::thread::_Invoker<std::tuple<mbgl::ThreadedSchedulerBase::makeSchedulerThread(size_t)::<lambda()> > > >::_M_run(void)(std::thread::_State_impl<std::thread::_Invoker<std::tuple<mbgl::ThreadedSchedulerBase::makeSchedulerThread(size_t)::<lambda()> > > > * const this) (\usr\include\c++\10\thread:215)
libstdc++.so.6![Unknown/Just-In-Time compiled code] (Unknown Source:0)
libpthread.so.0!start_thread(void * arg) (pthread_create.c:477)
libc.so.6!clone() (clone.S:95)
vinayakkulkarni commented 1 year ago

Reference Slack thread – https://osmus.slack.com/archives/C02B2CBSNBU/p1669928372999119

louwers commented 1 year ago

Yeah SymbolLayerFactory::createLayer should not be noexcept...