Hello, While debugging a pthread program that sets the stack size of pthreads, I've found out that the value PTHREAD_STACK_MIN is currently set (2048 bytes) seems to be way too low. As an example, the following simple program will segfault: --- #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #define MALLOC_SIZE 1024 void * foo(void *arg) { void *bar; bar = malloc(MALLOC_SIZE); assert(bar != NULL); return (NULL); } int main(void) { pthread_t thread; pthread_attr_t attr; int rc, i; rc = pthread_attr_init(&attr); assert(rc == 0); rc = pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); assert(rc == 0); rc = pthread_create(&thread, &attr, foo, NULL); assert(0 == rc); rc = pthread_join(thread, NULL); assert(0 == rc); exit(EXIT_SUCCESS); } --- IMHO, PTHREAD_STACK_MIN should be set to a sane value, that allows the thread to at least make use of libc functions. Roger.Received on Tue Mar 11 2014 - 16:07:35 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:47 UTC