forked from OSchip/llvm-project
[compiler-rt] [msan] Couple of fixes for msan with libc++
This patch adds some fixes for MSAN with libc++ for aarch64: 1. Adds the libmsan_loadable name for aarch64. 2. Fixes some pthread_attr_setstacksize for aarch64, since glibc sets the mininum stack size to be higher than the x86_64 default (16KB vs 128KB). 3. Fixes a swprintf null char constant definition. llvm-svn: 254015
This commit is contained in:
parent
4c31fcfcf5
commit
29ffb68259
|
@ -1883,7 +1883,7 @@ TEST(MemorySanitizer, swprintf) {
|
||||||
ASSERT_EQ(buff[1], '2');
|
ASSERT_EQ(buff[1], '2');
|
||||||
ASSERT_EQ(buff[2], '3');
|
ASSERT_EQ(buff[2], '3');
|
||||||
ASSERT_EQ(buff[6], '7');
|
ASSERT_EQ(buff[6], '7');
|
||||||
ASSERT_EQ(buff[7], 0);
|
ASSERT_EQ(buff[7], L'\0');
|
||||||
EXPECT_POISONED(buff[8]);
|
EXPECT_POISONED(buff[8]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2886,6 +2886,8 @@ static void GetPathToLoadable(char *buf, size_t sz) {
|
||||||
static const char basename[] = "libmsan_loadable.mips64.so";
|
static const char basename[] = "libmsan_loadable.mips64.so";
|
||||||
#elif defined(__mips64)
|
#elif defined(__mips64)
|
||||||
static const char basename[] = "libmsan_loadable.mips64el.so";
|
static const char basename[] = "libmsan_loadable.mips64el.so";
|
||||||
|
#elif defined(__aarch64__)
|
||||||
|
static const char basename[] = "libmsan_loadable.aarch64.so";
|
||||||
#endif
|
#endif
|
||||||
int res = snprintf(buf, sz, "%.*s/%s",
|
int res = snprintf(buf, sz, "%.*s/%s",
|
||||||
(int)dir_len, program_path, basename);
|
(int)dir_len, program_path, basename);
|
||||||
|
@ -2992,6 +2994,14 @@ static void *SmallStackThread_threadfn(void* data) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PTHREAD_STACK_MIN
|
||||||
|
# define SMALLSTACKSIZE PTHREAD_STACK_MIN
|
||||||
|
# define SMALLPRESTACKSIZE PTHREAD_STACK_MIN
|
||||||
|
#else
|
||||||
|
# define SMALLSTACKSIZE 64 * 1024
|
||||||
|
# define SMALLPRESTACKSIZE 16 * 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST(MemorySanitizer, SmallStackThread) {
|
TEST(MemorySanitizer, SmallStackThread) {
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_t t;
|
pthread_t t;
|
||||||
|
@ -2999,7 +3009,7 @@ TEST(MemorySanitizer, SmallStackThread) {
|
||||||
int res;
|
int res;
|
||||||
res = pthread_attr_init(&attr);
|
res = pthread_attr_init(&attr);
|
||||||
ASSERT_EQ(0, res);
|
ASSERT_EQ(0, res);
|
||||||
res = pthread_attr_setstacksize(&attr, 64 * 1024);
|
res = pthread_attr_setstacksize(&attr, SMALLSTACKSIZE);
|
||||||
ASSERT_EQ(0, res);
|
ASSERT_EQ(0, res);
|
||||||
res = pthread_create(&t, &attr, SmallStackThread_threadfn, NULL);
|
res = pthread_create(&t, &attr, SmallStackThread_threadfn, NULL);
|
||||||
ASSERT_EQ(0, res);
|
ASSERT_EQ(0, res);
|
||||||
|
@ -3016,7 +3026,7 @@ TEST(MemorySanitizer, SmallPreAllocatedStackThread) {
|
||||||
res = pthread_attr_init(&attr);
|
res = pthread_attr_init(&attr);
|
||||||
ASSERT_EQ(0, res);
|
ASSERT_EQ(0, res);
|
||||||
void *stack;
|
void *stack;
|
||||||
const size_t kStackSize = 16 * 1024;
|
const size_t kStackSize = SMALLPRESTACKSIZE;
|
||||||
res = posix_memalign(&stack, 4096, kStackSize);
|
res = posix_memalign(&stack, 4096, kStackSize);
|
||||||
ASSERT_EQ(0, res);
|
ASSERT_EQ(0, res);
|
||||||
res = pthread_attr_setstack(&attr, stack, kStackSize);
|
res = pthread_attr_setstack(&attr, stack, kStackSize);
|
||||||
|
|
Loading…
Reference in New Issue