diff options
author | Elliott Hughes <enh@google.com> | 2023-04-21 11:18:40 -0700 |
---|---|---|
committer | Cherrypicker Worker <android-build-cherrypicker-worker@google.com> | 2023-04-21 22:37:54 +0000 |
commit | d25afca1cc8f5b18310f6686174d184605f48573 (patch) | |
tree | b710ec6b97260436470a021f1c193645207a8cc0 | |
parent | 55c70807a6adc8a06b32aa7821c5a01133809b51 (diff) | |
download | bionic-d25afca1cc8f5b18310f6686174d184605f48573.tar.gz |
Fix pthread#pthread_heap_allocated_stack for jemalloc.
Since we need a page-aligned allocation for a thread stack, explicitly
ask for one. (Scudo happens to just give us one anyway for an allocation
this large, but 32-bit jemalloc does not.)
Bug: http://b/277598913
Test: treehugger
(cherry picked from https://android-review.googlesource.com/q/commit:18e335b3da7ae1afd74055cbe7f0d85541863691)
Merged-In: I41eeb6aadb6a22bf5d9619e768e5e0a76617f747
Change-Id: I41eeb6aadb6a22bf5d9619e768e5e0a76617f747
-rw-r--r-- | tests/pthread_test.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp index 06a0f3dc3..aad2a4df0 100644 --- a/tests/pthread_test.cpp +++ b/tests/pthread_test.cpp @@ -195,12 +195,12 @@ 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(); + std::unique_ptr<char[]> stack(new (std::align_val_t(getpagesize())) char[stack_size]); + memset(stack.get(), '\xff', stack_size); pthread_attr_t attr; ASSERT_EQ(0, pthread_attr_init(&attr)); - ASSERT_EQ(0, pthread_attr_setstack(&attr, stack, stack_size)); + ASSERT_EQ(0, pthread_attr_setstack(&attr, stack.get(), stack_size)); pthread_t t; ASSERT_EQ(0, pthread_create(&t, &attr, FnWithStackFrame, nullptr)); |