From 2513250be336ad92af47da2c225e7b7b69b9922f Mon Sep 17 00:00:00 2001 From: Kostya Kortchinsky Date: Mon, 28 Oct 2019 15:06:10 -0700 Subject: [PATCH] [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 --- compiler-rt/lib/scudo/standalone/list.h | 1 + .../lib/scudo/standalone/tests/list_test.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) 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 struct DoublyLinkedList : IntrusiveList { 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()); }