/* * Build: * cc -std=c99 -pedantic -Wall -pthread -o testcase testcase.c * * Takes single argument: amount of extra thread stack usage, in bytes. * Uses 1 byte without an argument. * Returns 0 in case of success. * Crashes with SIGSEGV for "large" argument, 10000 is enough for 14.4 * so exit status is 139 (decimal). */ #include #include #include #include #include void* threadfunc (void *bloat) { char buf[*(int*)bloat]; sigset_t mask; sigfillset(&mask); pthread_sigmask(SIG_SETMASK, &mask, NULL); syslog(LOG_NOTICE, "new thread: %p bloat %d buf %p", (void*)pthread_self(), *(int*)bloat, (void*)buf); return (NULL); } int main (int argc, char** argv) { pthread_t thread; pthread_attr_t pa; int bloat; openlog("testcase", LOG_PERROR|LOG_PID, LOG_USER); bloat = 1; if (argc > 1) bloat = atoi(argv[1]); syslog(LOG_NOTICE, "bloat set to %d", bloat); pthread_attr_init(&pa); pthread_attr_setstacksize(&pa, PTHREAD_STACK_MIN + 32768); pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED); pthread_create(&thread, &pa, threadfunc, &bloat); pthread_attr_destroy(&pa); usleep(12400); syslog(LOG_NOTICE, "main address: %p", (void*)pthread_self()); return (0); }