Date: Sat, 15 Mar 2003 00:31:46 -0800 From: David Schultz <das@FreeBSD.ORG> To: Ferruccio Vitale <ferruccio.vitale@tin.it> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: variable size too large? Message-ID: <20030315083146.GA25766@HAL9000.homeunix.com> In-Reply-To: <20030314153729.3825d4fe.ferruccio.vitale@tin.it> References: <20030314153729.3825d4fe.ferruccio.vitale@tin.it>
next in thread | previous in thread | raw e-mail | index | archive | help
Thus spake Ferruccio Vitale <ferruccio.vitale@tin.it>: > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030315083146.GA25766>