[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
This commit is contained in:
Kostya Kortchinsky 2019-10-28 15:06:10 -07:00 committed by Mitch Phillips
parent d83a2faacd
commit 2513250be3
2 changed files with 15 additions and 0 deletions

View File

@ -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;

View File

@ -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());
}