[compiler-rt] r373754 - [scudo][standalone] Make malloc_info return a minimal XML

Kostya Kortchinsky via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 08:46:35 PDT 2019


Author: cryptoad
Date: Fri Oct  4 08:46:34 2019
New Revision: 373754

URL: http://llvm.org/viewvc/llvm-project?rev=373754&view=rev
Log:
[scudo][standalone] Make malloc_info return a minimal XML

Summary:
Initially, our malloc_info was returning ENOTSUP, but Android would
rather have it return successfully and write a barebone XML to the
stream, so we will oblige.

Add an associated test.

Reviewers: cferris, morehouse, hctim, eugenis, vitalybuka

Reviewed By: morehouse

Subscribers: delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

Modified:
    compiler-rt/trunk/lib/scudo/standalone/tests/combined_test.cpp
    compiler-rt/trunk/lib/scudo/standalone/tests/wrappers_c_test.cpp
    compiler-rt/trunk/lib/scudo/standalone/wrappers_c.inc

Modified: compiler-rt/trunk/lib/scudo/standalone/tests/combined_test.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/tests/combined_test.cpp?rev=373754&r1=373753&r2=373754&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/tests/combined_test.cpp (original)
+++ compiler-rt/trunk/lib/scudo/standalone/tests/combined_test.cpp Fri Oct  4 08:46:34 2019
@@ -101,7 +101,7 @@ template <class Config> static void test
   // returns the same chunk. This requires that all the sizes we iterate on use
   // the same block size, but that should be the case for 2048 with our default
   // class size maps.
-  P  = Allocator->allocate(DataSize, Origin);
+  P = Allocator->allocate(DataSize, Origin);
   memset(P, Marker, DataSize);
   for (scudo::sptr Delta = -32; Delta < 32; Delta += 8) {
     const scudo::uptr NewSize = DataSize + Delta;

Modified: compiler-rt/trunk/lib/scudo/standalone/tests/wrappers_c_test.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/tests/wrappers_c_test.cpp?rev=373754&r1=373753&r2=373754&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/tests/wrappers_c_test.cpp (original)
+++ compiler-rt/trunk/lib/scudo/standalone/tests/wrappers_c_test.cpp Fri Oct  4 08:46:34 2019
@@ -281,3 +281,14 @@ TEST(ScudoWrappersCTest, MallocIterateBo
 
   free(P);
 }
+
+TEST(ScudoWrappersCTest, MallocInfo) {
+  char Buffer[64];
+  FILE *F = fmemopen(Buffer, sizeof(Buffer), "w+");
+  EXPECT_NE(F, nullptr);
+  errno = 0;
+  EXPECT_EQ(malloc_info(0, F), 0);
+  EXPECT_EQ(errno, 0);
+  fclose(F);
+  EXPECT_EQ(strncmp(Buffer, "<malloc version=\"scudo-", 23), 0);
+}

Modified: compiler-rt/trunk/lib/scudo/standalone/wrappers_c.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/wrappers_c.inc?rev=373754&r1=373753&r2=373754&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/wrappers_c.inc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/wrappers_c.inc Fri Oct  4 08:46:34 2019
@@ -179,7 +179,8 @@ INTERFACE WEAK void *SCUDO_PREFIX(aligne
       SCUDO_ALLOCATOR.allocate(size, scudo::Chunk::Origin::Malloc, alignment));
 }
 
-INTERFACE WEAK int SCUDO_PREFIX(malloc_info)(int, FILE *) {
-  errno = ENOTSUP;
-  return -1;
+INTERFACE WEAK int SCUDO_PREFIX(malloc_info)(UNUSED int options, FILE *stream) {
+  fputs("<malloc version=\"scudo-1\">", stream);
+  fputs("</malloc>", stream);
+  return 0;
 }




More information about the llvm-commits mailing list