From owner-freebsd-current Mon Apr 3 8:26:31 2000 Delivered-To: freebsd-current@freebsd.org Received: from tinker.exit.com (exit-gw.power.net [207.151.46.196]) by hub.freebsd.org (Postfix) with ESMTP id B371D37BEFD for ; Mon, 3 Apr 2000 08:26:24 -0700 (PDT) (envelope-from frank@exit.com) Received: from realtime.exit.com (realtime.exit.com [206.223.0.5]) by tinker.exit.com (8.9.3/8.9.3) with ESMTP id IAA93336 for ; Mon, 3 Apr 2000 08:26:21 -0700 (PDT) (envelope-from frank@exit.com) Received: (from frank@localhost) by realtime.exit.com (8.9.3/8.9.3) id IAA37084 for freebsd-current@freebsd.org; Mon, 3 Apr 2000 08:26:20 -0700 (PDT) (envelope-from frank) From: Frank Mayhar Message-Id: <200004031526.IAA37084@realtime.exit.com> Subject: Re: MLEN and crashes In-Reply-To: <19865.954756081@critter.freebsd.dk> from Poul-Henning Kamp at "Apr 3, 2000 12:01:21 pm" To: Poul-Henning Kamp Date: Mon, 3 Apr 2000 08:20:08 -0700 (PDT) Cc: Gary Jennejohn , Alfred Perlstein , Hellmuth Michaelis , freebsd-current@FreeBSD.ORGG Reply-To: frank@exit.com Organization: Exit Consulting X-Copyright0: Copyright 2000 Frank Mayhar. All Rights Reserved. X-Copyright1: Permission granted for electronic reproduction as Usenet News or email only. X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Poul-Henning Kamp wrote: > In message <200004030935.LAA48677@peedub.muc.de>, Gary Jennejohn writes: > > >Yes, but it was perfectly legal to put the structure on the stack > >_before_ MLEN was doubled. > > Just because it worked doesn't mean that it was correct. > > We need to be frugal about the kernel stack, for a lot of reasons, > that's just the way it is, and as far as I know it is the way > it will continue to be. To be a little less harsh about it (Poul, you could _really_ stand to work on your phrasing, this sounded unnecessarily harsh), kernel stack space is (in pretty much any kernel -- the one I work on is Unixware 7) a very scarce resource. You can put variables on the stack, but even that can make it run out for really long path lengths. If you have a structure or an array, the rule of thumb is to _always_ malloc it. This will save your bacon when the structure grows (as in this case) or the path gets a little longer, or something else happens that makes you run out of kernel stack. This is the way it is in kernel land. I won't say "get used to it," that's unnecessarily harsh, but it _is_ the way it is. Read, learn, evolve, as they say in talk.bizarre. And become a better kernel programmer thereby. -- Frank Mayhar frank@exit.com http://www.exit.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message