From 20d0ea792550bf0ebc848a306a4e184f5b38e323 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 30 Nov 2016 09:50:08 -0800 Subject: [PATCH] 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&) (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 const&) (server.cpp:141) ==9902== by 0x986603: lean::server::handle_request(nlohmann::basic_json 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&) (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 const&) (server.cpp:141) ==9902== by 0x986603: lean::server::handle_request(nlohmann::basic_json const&) (server.cpp:105) ==9902== by 0x986313: lean::server::run() (server.cpp:90) ==9902== by 0x975E98: main (lean.cpp:383) --- src/library/module_mgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/module_mgr.cpp b/src/library/module_mgr.cpp index 910670868c..124b18e265 100644 --- a/src/library/module_mgr.cpp +++ b/src/library/module_mgr.cpp @@ -21,7 +21,7 @@ namespace lean { void module_mgr::mark_out_of_date(module_id const & id, buffer & 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);