Merge "add test for using malloced stack for pthread_create" am: ee824ae6e0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2461793 Change-Id: I1a9bb430809793897e0828a40c4790940095d733 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
9cda760ab7
1 changed files with 25 additions and 0 deletions
|
@ -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 @@ TEST(pthread, pthread_key_dirty) {
|
|||
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.
|
||||
|
|
Loading…
Reference in a new issue