Merge "Add a test for snprintf on a PTHREAD_STACK_MIN-sized stack."
This commit is contained in:
commit
865f6bce75
|
@ -534,6 +534,25 @@ TEST(STDIO_TEST, snprintf_utf8_15439554) {
|
||||||
freelocale(cloc);
|
freelocale(cloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void* snprintf_small_stack_fn(void*) {
|
||||||
|
// Make life (realistically) hard for ourselves by allocating our own buffer for the result.
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
snprintf(buf, sizeof(buf), "/proc/%d", getpid());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(STDIO_TEST, snprintf_small_stack) {
|
||||||
|
// Is it safe to call snprintf on a thread with a small stack?
|
||||||
|
// (The snprintf implementation puts some pretty large buffers on the stack.)
|
||||||
|
pthread_attr_t a;
|
||||||
|
ASSERT_EQ(0, pthread_attr_init(&a));
|
||||||
|
ASSERT_EQ(0, pthread_attr_setstacksize(&a, PTHREAD_STACK_MIN));
|
||||||
|
|
||||||
|
pthread_t t;
|
||||||
|
ASSERT_EQ(0, pthread_create(&t, &a, snprintf_small_stack_fn, nullptr));
|
||||||
|
ASSERT_EQ(0, pthread_join(t, nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(STDIO_TEST, fprintf_failures_7229520) {
|
TEST(STDIO_TEST, fprintf_failures_7229520) {
|
||||||
// http://b/7229520
|
// http://b/7229520
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
|
|
|
@ -59,19 +59,13 @@ TEST(time, gmtime_no_stack_overflow_14313703) {
|
||||||
// Is it safe to call tzload on a thread with a small stack?
|
// Is it safe to call tzload on a thread with a small stack?
|
||||||
// http://b/14313703
|
// http://b/14313703
|
||||||
// https://code.google.com/p/android/issues/detail?id=61130
|
// https://code.google.com/p/android/issues/detail?id=61130
|
||||||
pthread_attr_t attributes;
|
pthread_attr_t a;
|
||||||
ASSERT_EQ(0, pthread_attr_init(&attributes));
|
ASSERT_EQ(0, pthread_attr_init(&a));
|
||||||
#if defined(__BIONIC__)
|
ASSERT_EQ(0, pthread_attr_setstacksize(&a, PTHREAD_STACK_MIN));
|
||||||
ASSERT_EQ(0, pthread_attr_setstacksize(&attributes, PTHREAD_STACK_MIN));
|
|
||||||
#else
|
|
||||||
// PTHREAD_STACK_MIN not currently in the host GCC sysroot.
|
|
||||||
ASSERT_EQ(0, pthread_attr_setstacksize(&attributes, 4 * getpagesize()));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pthread_t t;
|
pthread_t t;
|
||||||
ASSERT_EQ(0, pthread_create(&t, &attributes, gmtime_no_stack_overflow_14313703_fn, NULL));
|
ASSERT_EQ(0, pthread_create(&t, &a, gmtime_no_stack_overflow_14313703_fn, NULL));
|
||||||
void* result;
|
ASSERT_EQ(0, pthread_join(t, nullptr));
|
||||||
ASSERT_EQ(0, pthread_join(t, &result));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(time, mktime_empty_TZ) {
|
TEST(time, mktime_empty_TZ) {
|
||||||
|
|
Loading…
Reference in New Issue