PrintStatistics() and PrintStatisticsJSON() should take StatLock
authorDaniel Sanders <daniel_l_sanders@apple.com>
Tue, 6 Mar 2018 21:16:42 +0000 (21:16 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Tue, 6 Mar 2018 21:16:42 +0000 (21:16 +0000)
commit0f4b015268a5df4d95933761d3b999e09454fa3b
tree40ae3b6d8cb1eaa18c187ca0460de43d0cdbcf37
parent7dc51375811299e1f37b82703e6c54e8361c91a5
PrintStatistics() and PrintStatisticsJSON() should take StatLock

These two functions iterate over the list of statistics but don't take the lock
that protects the iterators from being invalidated by
StatisticInfo::addStatistic().

So far, this hasn't been an issue since (in-tree at least) these functions are
called by the StatisticInfo destructor so addStatistic() shouldn't be called
anymore. However, we do expose them in the public API.

Note that this only protects against iterator invalidation and does not protect
against ordering issues caused by statistic updates that race with
PrintStatistics()/PrintStatisticsJSON().

Thanks to Roman Tereshin for spotting it

llvm-svn: 326834
llvm/lib/Support/Statistic.cpp