From owner-freebsd-current@FreeBSD.ORG Tue Mar 11 17:07:35 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EE7E118F for ; Tue, 11 Mar 2014 17:07:35 +0000 (UTC) Received: from SMTP.CITRIX.COM (smtp.citrix.com [66.165.176.89]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4CF3AEF2 for ; Tue, 11 Mar 2014 17:07:35 +0000 (UTC) X-IronPort-AV: E=Sophos;i="4.97,632,1389744000"; d="scan'208";a="110294315" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 11 Mar 2014 17:07:26 +0000 Received: from [IPv6:::1] (10.80.16.47) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.2.342.4; Tue, 11 Mar 2014 13:07:25 -0400 Message-ID: <531F42CD.8020307@citrix.com> Date: Tue, 11 Mar 2014 18:07:25 +0100 From: =?ISO-8859-1?Q?Roger_Pau_Monn=E9?= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Subject: Too low PTHREAD_STACK_MIN value? X-Enigmail-Version: 1.6 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-DLP: MIA2 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Mar 2014 17:07:36 -0000 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 #include #include #include #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.