summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2016-02-29 16:54:18 +0000
committerMichael Kruse <llvm@meinersbur.de>2016-02-29 16:54:18 +0000
commit0b56681d21df79a242e4838c95abcdf193ef9974 (patch)
tree7f3c7cd7bfbe8fda79ce2476ab78ff99f09a5768
parent06d5af4c9dee685961e83c49e4c9ffb1cc054e56 (diff)
downloadbcm5719-llvm-0b56681d21df79a242e4838c95abcdf193ef9974.tar.gz
bcm5719-llvm-0b56681d21df79a242e4838c95abcdf193ef9974.zip
[ScopDetection] Fix use-after-free.
removeCachedResults deletes the DetectionContext from DetectionContextMap such that any it cannot be used anymore. Unfortunately invalid<ReportUnprofitable> and RejectLogs.insert still do use it. Because the memory is part of a map and not returned to to the OS immediatly, such that the observable effect was only a memory leak due to reference counters not decreased when the second call to removeCachedResults does not remove the DetectionContext because because it already has been removed. Fix by not removing the DetectionContext prematurely. The second call to removeCachedResults will handle it anyway. llvm-svn: 262235
-rw-r--r--polly/lib/Analysis/ScopDetection.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index f621b2d8fe5..4776a7f2ab8 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -1150,10 +1150,9 @@ void ScopDetection::findScops(Region &R) {
DetectionContext &Context = It.first->second;
bool RegionIsValid = false;
- if (!PollyProcessUnprofitable && regionWithoutLoops(R, LI)) {
- removeCachedResults(R);
+ if (!PollyProcessUnprofitable && regionWithoutLoops(R, LI))
invalid<ReportUnprofitable>(Context, /*Assert=*/true, &R);
- } else
+ else
RegionIsValid = isValidRegion(Context);
bool HasErrors = !RegionIsValid || Context.Log.size() > 0;
OpenPOWER on IntegriCloud