Merge tm-qpr-dev-plus-aosp-without-vendor@9467136
Bug: 264720040
Merged-In: Iab4145a18c9d216689d68b83adf747ec4f229ade
Change-Id: Ic44b43422c69813cb6c1aea52056b30bd108edfb
diff --git a/OWNERS b/OWNERS
index 670f88d..3818b1d 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,6 +1,7 @@
enh@google.com
cferris@google.com
+chiahungduan@google.com
danalbert@google.com
rprichard@google.com
yabinc@google.com
diff --git a/libc/bionic/malloc_common_dynamic.cpp b/libc/bionic/malloc_common_dynamic.cpp
index 97e8d15..802a94f 100644
--- a/libc/bionic/malloc_common_dynamic.cpp
+++ b/libc/bionic/malloc_common_dynamic.cpp
@@ -371,6 +371,7 @@
extern "C" const char* __scudo_get_stack_depot_addr();
extern "C" const char* __scudo_get_region_info_addr();
extern "C" const char* __scudo_get_ring_buffer_addr();
+extern "C" size_t __scudo_get_ring_buffer_size();
// Initializes memory allocation framework once per process.
static void MallocInitImpl(libc_globals* globals) {
@@ -383,6 +384,7 @@
__libc_shared_globals()->scudo_stack_depot = __scudo_get_stack_depot_addr();
__libc_shared_globals()->scudo_region_info = __scudo_get_region_info_addr();
__libc_shared_globals()->scudo_ring_buffer = __scudo_get_ring_buffer_addr();
+ __libc_shared_globals()->scudo_ring_buffer_size = __scudo_get_ring_buffer_size();
#endif
// Prefer malloc debug since it existed first and is a more complete
diff --git a/libc/include/inttypes.h b/libc/include/inttypes.h
index 7a409d8..f8b7f7d 100644
--- a/libc/include/inttypes.h
+++ b/libc/include/inttypes.h
@@ -257,10 +257,10 @@
__BEGIN_DECLS
intmax_t imaxabs(intmax_t __i) __attribute_const__ __INTRODUCED_IN(19);
imaxdiv_t imaxdiv(intmax_t __numerator, intmax_t __denominator) __attribute_const__ __INTRODUCED_IN(19);
-intmax_t strtoimax(const char* __s, char** __end_ptr, int __base);
-uintmax_t strtoumax(const char* __s, char** __end_ptr, int __base);
-intmax_t wcstoimax(const wchar_t* __s, wchar_t** __end_ptr, int __base) __INTRODUCED_IN(21);
-uintmax_t wcstoumax(const wchar_t* __s, wchar_t** __end_ptr, int __base) __INTRODUCED_IN(21);
+intmax_t strtoimax(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
+uintmax_t strtoumax(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
+intmax_t wcstoimax(const wchar_t* _Nonnull __s, wchar_t* _Nullable * _Nullable __end_ptr, int __base) __INTRODUCED_IN(21);
+uintmax_t wcstoumax(const wchar_t* _Nonnull __s, wchar_t* _Nullable * _Nullable __end_ptr, int __base) __INTRODUCED_IN(21);
__END_DECLS
#endif
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp
index e7a157e..373d497 100644
--- a/libc/malloc_debug/Android.bp
+++ b/libc/malloc_debug/Android.bp
@@ -176,6 +176,11 @@
"bionic_libc_platform_headers",
],
+ // The clang-analyzer-unix.Malloc and other warnings in these
+ // unit tests are either false positive or in
+ // negative tests that can be ignored.
+ tidy: false,
+
srcs: [
"tests/malloc_debug_system_tests.cpp",
],
diff --git a/libc/malloc_debug/RecordData.h b/libc/malloc_debug/RecordData.h
index 484d73b..a02c956 100644
--- a/libc/malloc_debug/RecordData.h
+++ b/libc/malloc_debug/RecordData.h
@@ -109,7 +109,7 @@
class CallocEntry : public MallocEntry {
public:
- CallocEntry(void* pointer, size_t size, size_t nmemb, uint64_t st, uint64_t et);
+ CallocEntry(void* pointer, size_t nmemb, size_t size, uint64_t st, uint64_t et);
virtual ~CallocEntry() = default;
bool Write(int fd) const override;
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 7c68242..4bc5649 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -943,7 +943,7 @@
if (g_debug->config().options() & RECORD_ALLOCS) {
g_debug->record->AddEntry(
- new CallocEntry(pointer, bytes, nmemb, result.GetStartTimeNS(), result.GetEndTimeNS()));
+ new CallocEntry(pointer, nmemb, bytes, result.GetStartTimeNS(), result.GetEndTimeNS()));
}
if (pointer != nullptr && g_debug->TrackPointers()) {
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
index 6215379..bf3ed14 100644
--- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
@@ -2196,7 +2196,7 @@
debug_free(pointer);
expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
- pointer = debug_calloc(1, 20);
+ pointer = debug_calloc(20, 1);
ASSERT_TRUE(pointer != nullptr);
expected.push_back(android::base::StringPrintf("%d: calloc %p 20 1", getpid(), pointer));
debug_free(pointer);
diff --git a/libc/malloc_hooks/Android.bp b/libc/malloc_hooks/Android.bp
index 01394da..6b4e606 100644
--- a/libc/malloc_hooks/Android.bp
+++ b/libc/malloc_hooks/Android.bp
@@ -59,6 +59,11 @@
name: "malloc_hooks_system_tests",
isolated: true,
+ // The clang-analyzer-unix.Malloc and other warnings in these
+ // unit tests are either false positive or in
+ // negative tests that can be ignored.
+ tidy: false,
+
srcs: [
"tests/malloc_hooks_tests.cpp",
],
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index c7e951d..520e50f 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -111,6 +111,7 @@
const char* scudo_stack_depot = nullptr;
const char* scudo_region_info = nullptr;
const char* scudo_ring_buffer = nullptr;
+ size_t scudo_ring_buffer_size = 0;
HeapTaggingLevel initial_heap_tagging_level = M_HEAP_TAGGING_LEVEL_NONE;
bool initial_memtag_stack = false;
diff --git a/linker/linker_debuggerd_android.cpp b/linker/linker_debuggerd_android.cpp
index cba6345..3d64628 100644
--- a/linker/linker_debuggerd_android.cpp
+++ b/linker/linker_debuggerd_android.cpp
@@ -43,6 +43,7 @@
.scudo_stack_depot = __libc_shared_globals()->scudo_stack_depot,
.scudo_region_info = __libc_shared_globals()->scudo_region_info,
.scudo_ring_buffer = __libc_shared_globals()->scudo_ring_buffer,
+ .scudo_ring_buffer_size = __libc_shared_globals()->scudo_ring_buffer_size,
};
}
#endif