From owner-freebsd-stable@FreeBSD.ORG Fri Dec 23 22:54:47 2011 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9BF88106566B for ; Fri, 23 Dec 2011 22:54:47 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from qmta14.emeryville.ca.mail.comcast.net (qmta14.emeryville.ca.mail.comcast.net [76.96.27.212]) by mx1.freebsd.org (Postfix) with ESMTP id 80C1A8FC16 for ; Fri, 23 Dec 2011 22:54:47 +0000 (UTC) Received: from omta23.emeryville.ca.mail.comcast.net ([76.96.30.90]) by qmta14.emeryville.ca.mail.comcast.net with comcast id Cmkn1i0051wfjNsAEmugZy; Fri, 23 Dec 2011 22:54:40 +0000 Received: from koitsu.dyndns.org ([67.180.84.87]) by omta23.emeryville.ca.mail.comcast.net with comcast id CmlY1i00L1t3BNj8jmlYg7; Fri, 23 Dec 2011 22:45:32 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id C04AB102C19; Fri, 23 Dec 2011 14:54:45 -0800 (PST) Date: Fri, 23 Dec 2011 14:54:45 -0800 From: Jeremy Chadwick To: Charlie Martin Message-ID: <20111223225445.GA29093@icarus.home.lan> References: <4EF3B790.5050509@sgi.com> <20111223000705.GA6242@icarus.home.lan> <4EF4FED2.6020909@sgi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4EF4FED2.6020909@sgi.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Eric Richards , Larry Fenske , freebsd-stable@FreeBSD.org, "Peter W. Morreale" Subject: Re: PRINTF_BUFR_SIZE=4096? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Dec 2011 22:54:47 -0000 On Fri, Dec 23, 2011 at 03:21:06PM -0700, Charlie Martin wrote: > In the course of looking at Jeremy's reponse to my query about a > mystery panic, I noted his recommendation that PRINTF_BUFR_SIZE be > set to 256. Ever-obedient, I went to set the value, and discovered > instead that the conf file already has it set to 4096. > > As he says below, there are concerns about setting the value too > high causing "major issues". > > I being Christmas and all I hate to ask Jeremy to dig up the post he > mentioned, but wonder if anyone can clue me in on what the major > issues might be? As Andriy pointed out, potential stack overflow is the concern. The buffer size defined in the config file is allocated on the stack (e.g. char buf[4096]). The concern was mentioned by Kris Kenneway (and this is the post I eluded to): http://lists.freebsd.org/pipermail/freebsd-current/2008-February/083454.html When I was doing FreeBSD "stuff" as part of the Project, I added this to my Commonly Reported Issues wiki page since it comes up quite often. Search for "BUFR". http://wiki.freebsd.org/BugBusting/Commonly_reported_issues John Baldwin also chimed in with some insights a few years later: http://unix.derkeiler.com/Mailing-Lists/FreeBSD/current/2010-06/msg00545.html http://unix.derkeiler.com/Mailing-Lists/FreeBSD/current/2010-06/msg00632.html I had a conversation with John (I thought publicly but I can't find it; it's probably in my mail archives though) about this, as he has some ideas on how to solve it but he would need the time to work on it. I'll point out, however, that ddb(4) and dtrace debug (I think for debugging dtrace itself, not sure) kernel bits both use this same methodology (allocated buffer on the stack). See DDB_BUFR_SIZE and DTRACE_DEBUG_BUFR_SIZE. Linux solved this problem in a roundabout way, by implementing a "ring buffer" for klogd (kernel logging daemon). The below document looks daunting given its length and diagrams, but it's actually quite clever (well I thought so anyway): http://www.mjmwired.net/kernel/Documentation/trace/ring-buffer-design.txt Other info: http://www.makelinux.net/ldd3/chp-4-sect-2 > On 12/22/2011 05:07 PM, Jeremy Chadwick wrote: > >Also, be aware that the above stack trace is interspersed. Ultimately > >you get to clean up the output yourself. This is a long-standing > >problem with FreeBSD which can be helped but only slightly/barely by > >using "options PRINTF_BUFR_SIZE=256" in your kernel configuration (the > >default configs have a value of 128. Do not increase the value too > >high, there are concerns about it causing major issues; I can dig up the > >post that says that, but I'd rather not). -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, US | | Making life hard for others since 1977. PGP 4BD6C0CB |