fix(library/module_mgr): invalid memory read

@gebner I was getting the following error with valgrind:

==9902== Invalid read of size 1
==9902==    at 0xAD209B: lean::module_mgr::mark_out_of_date(std::string const&, lean::buffer<std::string, 16u>&) (module_mgr.cpp:24)
==9902==    by 0xAD3EF5: lean::module_mgr::invalidate(std::string const&) (module_mgr.cpp:286)
==9902==    by 0x986A84: lean::server::handle_sync(nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator> const&) (server.cpp:141)
==9902==    by 0x986603: lean::server::handle_request(nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator> const&) (server.cpp:105)
==9902==    by 0x986313: lean::server::run() (server.cpp:90)
==9902==    by 0x975E98: main (lean.cpp:383)
==9902==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==9902==
==9902==
==9902== Process terminating with default action of signal 11 (SIGSEGV)
==9902==  Access not within mapped region at address 0x0
==9902==    at 0xAD209B: lean::module_mgr::mark_out_of_date(std::string const&, lean::buffer<std::string, 16u>&) (module_mgr.cpp:24)
==9902==    by 0xAD3EF5: lean::module_mgr::invalidate(std::string const&) (module_mgr.cpp:286)
==9902==    by 0x986A84: lean::server::handle_sync(nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator> const&) (server.cpp:141)
==9902==    by 0x986603: lean::server::handle_request(nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator> const&) (server.cpp:105)
==9902==    by 0x986313: lean::server::run() (server.cpp:90)
==9902==    by 0x975E98: main (lean.cpp:383)
This commit is contained in:
Leonardo de Moura 2016-11-30 09:50:08 -08:00
parent d542e95d20
commit 20d0ea7925

View file

@ -21,7 +21,7 @@ namespace lean {
void module_mgr::mark_out_of_date(module_id const & id, buffer<module_id> & to_rebuild) {
for (auto & mod : m_modules) {
if (mod.second->m_out_of_date) continue;
if (!mod.second || mod.second->m_out_of_date) continue;
for (auto & dep : mod.second->m_deps) {
if (dep.first == id) {
to_rebuild.push_back(mod.first);