Skip to content

Commit

Permalink
[Fix] Guard AnalysisResult::m_files with a lock
Browse files Browse the repository at this point in the history
Summary: For parse-on-demand, we were checking to see if a file had already
been parsed without aquiring a lock. That could result in a crash if files were
inserted during the lookup.

Test Plan: Running the command from the task resulted in a crash once in about
10 tries before the fix. After the fix I ran it 3000 times with no failures.

Reviewers: qigao, myang

Reviewed By: qigao

CC: ps, mwilliams, qigao

Differential Revision: 351734

Task ID: 778331
  • Loading branch information
mwilliams authored and macvicar committed Nov 29, 2011
1 parent 690f237 commit daf2b56
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/compiler/analysis/analysis_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,14 @@ void AnalysisResult::parseOnDemand(const std::string &name) const {
if (name.find(root) == 0) {
rname = name.substr(root.length());
}
if (m_files.find(rname) == m_files.end() &&
(m_parseOnDemand || inParseOnDemandDirs(rname)) &&
if ((m_parseOnDemand || inParseOnDemandDirs(rname)) &&
Option::PackageExcludeFiles.find(rname) ==
Option::PackageExcludeFiles.end() &&
!Option::IsFileExcluded(rname, Option::PackageExcludePatterns)) {
{
Locker l(this);
if (m_files.find(rname) != m_files.end()) return;
}
m_package->addSourceFile(rname.c_str());
}
}
Expand Down

0 comments on commit daf2b56

Please sign in to comment.