From 23919b915f2eeba787fd773b9e59f6e9668b1cd2 Mon Sep 17 00:00:00 2001 From: mwilliams Date: Sun, 26 May 2013 17:25:32 -0700 Subject: [PATCH] Fix crash/hang in Parser::newClosureName The parser was updating a static std::map without a lock. It looks like this is supposed to be local to a file anyway, so add the map as a member of ParserBase. --- hphp/util/parser/parser.cpp | 3 +-- hphp/util/parser/parser.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hphp/util/parser/parser.cpp b/hphp/util/parser/parser.cpp index a2f864673..f679c63d3 100644 --- a/hphp/util/parser/parser.cpp +++ b/hphp/util/parser/parser.cpp @@ -53,8 +53,7 @@ std::string ParserBase::newClosureName( } name += funcName; - static std::map s_seenClosures; - int id = ++s_seenClosures[name]; + int id = ++m_seenClosures[name]; if (id > 1) { // we've seen the same name before, uniquify name = name + '#' + std::to_string(id); diff --git a/hphp/util/parser/parser.h b/hphp/util/parser/parser.h index 892fdafea..de5a1480e 100644 --- a/hphp/util/parser/parser.h +++ b/hphp/util/parser/parser.h @@ -199,6 +199,7 @@ protected: bool m_nsFileScope; std::string m_namespace; // current namespace hphp_string_imap m_aliases; + hphp_string_imap m_seenClosures; }; ///////////////////////////////////////////////////////////////////////////////