Skip to content

Commit d4f3e84

Browse files
toddlipconcopybara-github
authored andcommitted
Re-enable size class checks when freeing spans
Performance overhead of these checks was determined to be negligible. PiperOrigin-RevId: 816792943 Change-Id: I223cb605b0c774f9c317685b5b053aa9b3e09a38
1 parent 9606020 commit d4f3e84

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tcmalloc/central_freelist.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,18 @@ Length StaticForwarder::class_to_pages(int size_class) {
7474

7575
void StaticForwarder::MapObjectsToSpans(absl::Span<void*> batch, Span** spans,
7676
int expected_size_class) {
77-
// TODO(b/396002858): Resume using expected_size_class or remove it.
78-
(void)expected_size_class;
79-
8077
// Prefetch Span objects to reduce cache misses.
8178
for (int i = 0; i < batch.size(); ++i) {
8279
const PageId p = PageIdContaining(batch[i]);
83-
Span* span = tc_globals.pagemap().GetExistingDescriptor(p);
80+
auto [span, page_size_class] =
81+
tc_globals.pagemap().GetExistingDescriptorAndSizeClass(p);
8482
if (ABSL_PREDICT_FALSE(span == nullptr)) {
8583
ReportDoubleFree(tc_globals, batch[i]);
8684
}
85+
if (ABSL_PREDICT_FALSE(page_size_class != expected_size_class)) {
86+
ReportMismatchedSizeClass(tc_globals, span, page_size_class,
87+
expected_size_class);
88+
}
8789
span->Prefetch();
8890
spans[i] = span;
8991
}

tcmalloc/testing/memory_errors_test.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,7 @@ TEST_F(TcMallocTest, MismatchedDeleteTooSmall) {
699699
}
700700
}
701701

702-
TEST_F(TcMallocTest, DISABLED_MismatchedSizeClassInFreelistInsertion) {
703-
// TODO(b/396002858): Reenable this test.
704-
702+
TEST_F(TcMallocTest, MismatchedSizeClassInFreelistInsertion) {
705703
#ifdef ABSL_HAVE_ADDRESS_SANITIZER
706704
GTEST_SKIP() << "ASan will trap ahead of us";
707705
#endif

0 commit comments

Comments
 (0)