shared_ptr returned from getAvailableFeatures() was released before the for loop iterated over it.
Shared pointer was removed, it only complicated the code.
==16910== Thread 39 civetweb-worker:
==16910== Invalid read of size 8
==16910== at 0xA12095: __gnu_cxx::__normal_iterator<dss::ModelFeatureId*, std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > >::__normal_iterator(dss::ModelFeatureId* const&) (stl_iterator.h:777)
==16910== by 0xA12053: std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >::begin() (stl_vector.h:549)
==16910== by 0xA12009: boost::range_iterator<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >, void>::type boost::range_detail::range_begin<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > >(std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >&) (begin.hpp:47)
==16910== by 0xA11F59: boost::range_iterator<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >, void>::type boost::range_adl_barrier::begin<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > >(std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >&) (begin.hpp:102)
==16910== by 0xA10EA1: boost::foreach_detail_::auto_any<boost::foreach_detail_::foreach_iterator<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >, mpl_::bool_<false> >::type> boost::foreach_detail_::begin<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >, mpl_::bool_<false> >(boost::foreach_detail_::auto_any_base const&, boost::foreach_detail_::type2type<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >, mpl_::bool_<false> >*, mpl_::bool_<false>*) (foreach.hpp:673)
==16910== by 0xA0DA03: dss::ApartmentRequestHandler::jsonHandleRequest(dss::RestfulRequest const&, boost::shared_ptr<dss::Session>, mg_connection const*) (apartmentrequesthandler.cpp:501)
==16910== by 0x996B26: dss::WebServer::jsonHandler(mg_connection*, dss::RestfulRequest&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::shared_ptr<dss::Session>) (webserver.cpp:405)
==16910== by 0x996378: dss::WebServer::httpRequestCallback(mg_connection*, void*) (webserver.cpp:716)
==16910== by 0xAADF0D: handle_request (civetweb.c:9145)
==16910== by 0xAAD8F8: process_new_connection (civetweb.c:10984)
==16910== by 0xAAD493: worker_thread_run (civetweb.c:11148)
==16910== by 0xAA7572: worker_thread (civetweb.c:11183)
==16910== Address 0x44cf4200 is 32 bytes inside a block of size 56 free'd
==16910== at 0x4C2D22A: operator delete(void*) (vg_replace_malloc.c:576)
==16910== by 0x812DB2: boost::detail::sp_counted_impl_pd<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >*, boost::detail::sp_ms_deleter<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > > >::~sp_counted_impl_pd() (sp_counted_impl.hpp:127)
==16910== by 0x770AEF: boost::detail::sp_counted_base::destroy() (sp_counted_base_clang.hpp:92)
==16910== by 0x74D05C: boost::detail::sp_counted_base::weak_release() (sp_counted_base_clang.hpp:126)
==16910== by 0x74CFD4: boost::detail::sp_counted_base::release() (sp_counted_base_clang.hpp:113)
==16910== by 0x74CF71: boost::detail::shared_count::~shared_count() (shared_count.hpp:473)
==16910== by 0x81194D: boost::shared_ptr<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > >::~shared_ptr() (shared_ptr.hpp:762)
==16910== by 0xA0D9F0: dss::ApartmentRequestHandler::jsonHandleRequest(dss::RestfulRequest const&, boost::shared_ptr<dss::Session>, mg_connection const*) (apartmentrequesthandler.cpp:501)
==16910== by 0x996B26: dss::WebServer::jsonHandler(mg_connection*, dss::RestfulRequest&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::shared_ptr<dss::Session>) (webserver.cpp:405)
==16910== by 0x996378: dss::WebServer::httpRequestCallback(mg_connection*, void*) (webserver.cpp:716)
==16910== by 0xAADF0D: handle_request (civetweb.c:9145)
==16910== by 0xAAD8F8: process_new_connection (civetweb.c:10984)
==16910== Block was alloc'd at
==16910== at 0x4C2C20C: operator new(unsigned long) (vg_replace_malloc.c:334)
==16910== by 0x812BED: boost::detail::shared_count::shared_count<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >*, boost::detail::sp_ms_deleter<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > > >(std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >*, boost::detail::sp_inplace_tag<boost::detail::sp_ms_deleter<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > > >) (shared_count.hpp:206)
==16910== by 0x812A60: boost::shared_ptr<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > >::shared_ptr<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >, boost::detail::sp_inplace_tag<boost::detail::sp_ms_deleter<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > > > >(std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >*, boost::detail::sp_inplace_tag<boost::detail::sp_ms_deleter<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > > >) (shared_ptr.hpp:371)
==16910== by 0x8118CC: boost::detail::sp_if_not_array<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> > >::type boost::make_shared<std::vector<dss::ModelFeatureId, std::allocator<dss::ModelFeatureId> >>() (make_shared_object.hpp:248)
==16910== by 0x811718: dss::ModelFeatures::getAvailableFeatures() (model-features.cpp:996)
==16910== by 0xA0D9C8: dss::ApartmentRequestHandler::jsonHandleRequest(dss::RestfulRequest const&, boost::shared_ptr<dss::Session>, mg_connection const*) (apartmentrequesthandler.cpp:501)
==16910== by 0x996B26: dss::WebServer::jsonHandler(mg_connection*, dss::RestfulRequest&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::shared_ptr<dss::Session>) (webserver.cpp:405)
==16910== by 0x996378: dss::WebServer::httpRequestCallback(mg_connection*, void*) (webserver.cpp:716)
==16910== by 0xAADF0D: handle_request (civetweb.c:9145)
==16910== by 0xAAD8F8: process_new_connection (civetweb.c:10984)
==16910== by 0xAAD493: worker_thread_run (civetweb.c:11148)
==16910== by 0xAA7572: worker_thread (civetweb.c:11183)