diff --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
--- a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
@@ -303,7 +303,11 @@
#if !SCUDO_FUCHSIA
TEST(ScudoWrappersCTest, MallocInfo) {
- char Buffer[64];
+ // Use volatile so that the allocations don't get optimized away.
+ void *volatile P1 = malloc(1234);
+ void *volatile P2 = malloc(4321);
+
+ char Buffer[16384];
FILE *F = fmemopen(Buffer, sizeof(Buffer), "w+");
EXPECT_NE(F, nullptr);
errno = 0;
@@ -311,6 +315,11 @@
EXPECT_EQ(errno, 0);
fclose(F);
EXPECT_EQ(strncmp(Buffer, "", stream);
- fputs("", stream);
+ const scudo::uptr max_size =
+ decltype(SCUDO_ALLOCATOR)::PrimaryT::SizeClassMap::MaxSize;
+ scudo::uptr sizes[max_size] = {};
+ auto callback = [](uintptr_t, size_t size, void* arg) {
+ auto *sizes = reinterpret_cast(arg);
+ if (size < max_size)
+ sizes[size]++;
+ };
+ SCUDO_ALLOCATOR.iterateOverChunks(0, -1ul, callback, sizes);
+
+ fputs("\n", stream);
+ for (scudo::uptr i = 0; i != max_size; ++i)
+ if (sizes[i])
+ fprintf(stream, "\n", i, sizes[i]);
+ fputs("\n", stream);
return 0;
}