Merge "Add the %b/%B PRI* and SCN* macros."
diff --git a/libc/Android.bp b/libc/Android.bp
index e5a7454..c101f45 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -672,7 +672,6 @@
},
riscv64: {
srcs: [
- "arch-riscv64/string/memset_chk.c",
"upstream-freebsd/lib/libc/string/memcmp.c",
"upstream-freebsd/lib/libc/string/memcpy.c",
"upstream-freebsd/lib/libc/string/memmove.c",
@@ -825,6 +824,11 @@
"arch-arm64/string/__memset_chk.S",
],
},
+ riscv64: {
+ srcs: [
+ "arch-riscv64/string/__memset_chk.S",
+ ],
+ },
},
}
diff --git a/libc/arch-riscv64/string/__memset_chk.S b/libc/arch-riscv64/string/__memset_chk.S
new file mode 100644
index 0000000..a5562cb
--- /dev/null
+++ b/libc/arch-riscv64/string/__memset_chk.S
@@ -0,0 +1,10 @@
+#include <private/bionic_asm.h>
+
+ENTRY(__memset_chk)
+ bleu a2, a3, 1f
+ call __memset_chk_fail
+
+1:
+ tail memset
+END(__memset_chk)
+
diff --git a/libc/arch-riscv64/string/memset_chk.c b/libc/arch-riscv64/string/memset_chk.c
deleted file mode 100644
index bdd15a5..0000000
--- a/libc/arch-riscv64/string/memset_chk.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stdint.h>
-
-extern void* memset(void*, int, size_t);
-extern void* __memset_chk_fail(void*, int, size_t, size_t);
-
-void* __memset_chk(void* dst, int c, size_t n, size_t dst_len) {
- if (dst_len < n) __memset_chk_fail(dst, c, n, dst_len);
- return memset(dst, c, n);
-}
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index 4f12fd0..645aefa 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -884,7 +884,7 @@
void perror(const char* msg) {
if (msg == nullptr) msg = "";
- fprintf(stderr, "%s%s%s\n", msg, (*msg == '\0') ? "" : ": ", strerror(errno));
+ fprintf(stderr, "%s%s%m\n", msg, (*msg == '\0') ? "" : ": ");
}
int printf(const char* fmt, ...) {
diff --git a/tests/gwp_asan_test.cpp b/tests/gwp_asan_test.cpp
index 38661c7..8b12bec 100644
--- a/tests/gwp_asan_test.cpp
+++ b/tests/gwp_asan_test.cpp
@@ -58,13 +58,10 @@
// the torture mode is is generally 40,000, so that svelte devices don't
// explode, as this uses ~163MiB RAM (4KiB per live allocation).
TEST(gwp_asan_integration, malloc_tests_under_torture) {
- if (running_with_hwasan()) {
- // Skip the malloc.zeroed tests since they fail in this particular config.
- // TODO(b/267386540): Need to fix this problem.
- RunGwpAsanTest("malloc.*:-malloc.mallinfo*:malloc.zeroed*");
- } else {
- RunGwpAsanTest("malloc.*:-malloc.mallinfo*");
- }
+ // Do not override HWASan with GWP ASan.
+ SKIP_WITH_HWASAN;
+
+ RunGwpAsanTest("malloc.*:-malloc.mallinfo*");
}
class SyspropRestorer {
@@ -153,6 +150,9 @@
}
TEST(gwp_asan_integration, sysprops_program_specific) {
+ // Do not override HWASan with GWP ASan.
+ SKIP_WITH_HWASAN;
+
SyspropRestorer restorer;
std::string path = testing::internal::GetArgvs()[0];
@@ -167,6 +167,9 @@
}
TEST(gwp_asan_integration, sysprops_persist_program_specific) {
+ // Do not override HWASan with GWP ASan.
+ SKIP_WITH_HWASAN;
+
SyspropRestorer restorer;
std::string path = testing::internal::GetArgvs()[0];
@@ -182,6 +185,9 @@
}
TEST(gwp_asan_integration, sysprops_system) {
+ // Do not override HWASan with GWP ASan.
+ SKIP_WITH_HWASAN;
+
SyspropRestorer restorer;
__system_property_set("libc.debug.gwp_asan.sample_rate.system_default", "1");
@@ -192,6 +198,9 @@
}
TEST(gwp_asan_integration, sysprops_persist_system) {
+ // Do not override HWASan with GWP ASan.
+ SKIP_WITH_HWASAN;
+
SyspropRestorer restorer;
__system_property_set("persist.libc.debug.gwp_asan.sample_rate.system_default", "1");
@@ -202,6 +211,9 @@
}
TEST(gwp_asan_integration, sysprops_non_persist_overrides_persist) {
+ // Do not override HWASan with GWP ASan.
+ SKIP_WITH_HWASAN;
+
SyspropRestorer restorer;
__system_property_set("libc.debug.gwp_asan.sample_rate.system_default", "1");
@@ -216,6 +228,9 @@
}
TEST(gwp_asan_integration, sysprops_program_specific_overrides_default) {
+ // Do not override HWASan with GWP ASan.
+ SKIP_WITH_HWASAN;
+
SyspropRestorer restorer;
std::string path = testing::internal::GetArgvs()[0];
@@ -235,6 +250,9 @@
}
TEST(gwp_asan_integration, sysprops_can_disable) {
+ // Do not override HWASan with GWP ASan.
+ SKIP_WITH_HWASAN;
+
SyspropRestorer restorer;
__system_property_set("libc.debug.gwp_asan.sample_rate.system_default", "0");
@@ -245,6 +263,9 @@
}
TEST(gwp_asan_integration, env_overrides_sysprop) {
+ // Do not override HWASan with GWP ASan.
+ SKIP_WITH_HWASAN;
+
SyspropRestorer restorer;
__system_property_set("libc.debug.gwp_asan.sample_rate.system_default", "0");
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 907a35c..06a0f3d 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -41,6 +41,7 @@
#include <android-base/scopeguard.h>
#include <android-base/silent_death_test.h>
#include <android-base/strings.h>
+#include <android-base/test_utils.h>
#include "private/bionic_constants.h"
#include "SignalUtils.h"
@@ -184,6 +185,30 @@
ASSERT_EQ(0, pthread_key_delete(key));
}
+static void* FnWithStackFrame(void*) {
+ int x;
+ *const_cast<volatile int*>(&x) = 1;
+ return nullptr;
+}
+
+TEST(pthread, pthread_heap_allocated_stack) {
+ SKIP_WITH_HWASAN; // TODO(b/148982147): Re-enable when fixed.
+
+ size_t stack_size = 640 * 1024;
+ std::vector<char> stack_vec(stack_size, '\xff');
+ void* stack = stack_vec.data();
+
+ pthread_attr_t attr;
+ ASSERT_EQ(0, pthread_attr_init(&attr));
+ ASSERT_EQ(0, pthread_attr_setstack(&attr, stack, stack_size));
+
+ pthread_t t;
+ ASSERT_EQ(0, pthread_create(&t, &attr, FnWithStackFrame, nullptr));
+
+ void* result;
+ ASSERT_EQ(0, pthread_join(t, &result));
+}
+
TEST(pthread, static_pthread_key_used_before_creation) {
#if defined(__BIONIC__)
// See http://b/19625804. The bug is about a static/global pthread key being used before creation.