[compiler-rt] 2513250 - [scudo][standalone] Lists fix

Mitch Phillips via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 28 15:08:19 PDT 2019


Author: Kostya Kortchinsky
Date: 2019-10-28T15:08:08-07:00
New Revision: 2513250be336ad92af47da2c225e7b7b69b9922f

URL: https://github.com/llvm/llvm-project/commit/2513250be336ad92af47da2c225e7b7b69b9922f
DIFF: https://github.com/llvm/llvm-project/commit/2513250be336ad92af47da2c225e7b7b69b9922f.diff

LOG: [scudo][standalone] Lists fix

Summary:
Apparently during the review of D69265, and my flailing around with
git, a somewhat important line disappeared.

On top of that, there was no test exercising that code path, and
while writing the follow up patch I intended to write, some `CHECK`s
were failing.

Re-add the missing line, and add a test that fails without said line.

Reviewers: hctim, morehouse, pcc, cferris

Reviewed By: hctim

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D69529

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/list.h
    compiler-rt/lib/scudo/standalone/tests/list_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/list.h b/compiler-rt/lib/scudo/standalone/list.h
index ca5b3167ab04..c3b898a328ca 100644
--- a/compiler-rt/lib/scudo/standalone/list.h
+++ b/compiler-rt/lib/scudo/standalone/list.h
@@ -148,6 +148,7 @@ template <class T> struct DoublyLinkedList : IntrusiveList<T> {
       Last = X;
     } else {
       DCHECK_EQ(First->Prev, nullptr);
+      First->Prev = X;
     }
     X->Next = First;
     First = X;

diff  --git a/compiler-rt/lib/scudo/standalone/tests/list_test.cpp b/compiler-rt/lib/scudo/standalone/tests/list_test.cpp
index c303885f6c20..0a0c050c98cd 100644
--- a/compiler-rt/lib/scudo/standalone/tests/list_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/list_test.cpp
@@ -194,4 +194,18 @@ TEST(ScudoListTest, DoublyLinkedList) {
   L.checkConsistency();
   L.pop_front();
   EXPECT_TRUE(L.empty());
+
+  L.push_back(X);
+  L.insert(Y, X);
+  EXPECT_EQ(L.size(), 2U);
+  EXPECT_EQ(L.front(), Y);
+  EXPECT_EQ(L.back(), X);
+  L.checkConsistency();
+  L.remove(Y);
+  EXPECT_EQ(L.size(), 1U);
+  EXPECT_EQ(L.front(), X);
+  EXPECT_EQ(L.back(), X);
+  L.checkConsistency();
+  L.pop_front();
+  EXPECT_TRUE(L.empty());
 }


        


More information about the llvm-commits mailing list