From owner-freebsd-hackers Sat Mar 15 0:31:51 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3C35237B401 for ; Sat, 15 Mar 2003 00:31:50 -0800 (PST) Received: from HAL9000.homeunix.com (12-233-57-224.client.attbi.com [12.233.57.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id B387743FB1 for ; Sat, 15 Mar 2003 00:31:49 -0800 (PST) (envelope-from das@FreeBSD.ORG) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.6/8.12.5) with ESMTP id h2F8VlIX025896; Sat, 15 Mar 2003 00:31:47 -0800 (PST) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.6/8.12.5/Submit) id h2F8VkHo025895; Sat, 15 Mar 2003 00:31:46 -0800 (PST) (envelope-from das@FreeBSD.ORG) Date: Sat, 15 Mar 2003 00:31:46 -0800 From: David Schultz To: Ferruccio Vitale Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: variable size too large? Message-ID: <20030315083146.GA25766@HAL9000.homeunix.com> Mail-Followup-To: Ferruccio Vitale , freebsd-hackers@FreeBSD.ORG References: <20030314153729.3825d4fe.ferruccio.vitale@tin.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030314153729.3825d4fe.ferruccio.vitale@tin.it> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Thus spake Ferruccio Vitale : > I'm writing a little multithread program: in my thread function, I allocated a char variable of IP_MAXPACKET size; when I try to compile it, everything goes well, but when I run it, it dies, making a core file. > Assume that: > 1) the same code, with only one thread, linked to libc, runs normally > 2) the same code, with a smaller variable size, linked to libc_r, runs normally > 3) I tried to allocate two variables of 64000 bytes in this function (IP_MAXPACKET is equal to 65535), linked to libc_r and runs normally > > Where am I wrong? :)) Threads get much smaller stacks by default than monolithic processes. You should avoid making large allocations on the stack in order to avoid this problem. Use malloc()/free() instead. (You can kludge around the problem by using larger stack sizes, but you really shouldn't.) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message