From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 23 21:07:07 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C1A33106566B; Tue, 23 Mar 2010 21:07:07 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 7CFE48FC14; Tue, 23 Mar 2010 21:07:07 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 82D0D1FFC22; Tue, 23 Mar 2010 21:07:06 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id 63705844DA; Tue, 23 Mar 2010 22:07:06 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: John Baldwin References: <86ocifcmew.fsf@ds4.des.no> <201003231000.58961.jhb@freebsd.org> Date: Tue, 23 Mar 2010 22:07:05 +0100 In-Reply-To: <201003231000.58961.jhb@freebsd.org> (John Baldwin's message of "Tue, 23 Mar 2010 10:00:58 -0400") Message-ID: <86zl1y4uiu.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.95 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org, Dmitry Krivenok Subject: Re: Strange behavior of kernel module (output terminated) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Mar 2010 21:07:07 -0000 John Baldwin writes: > Dag-Erling Sm=C3=B8rgrav writes: > > I'm not sure it's such a good idea to use uprintf() here. The event > > handler can be called in non-process context. > If you are doing a kldload post-boot it is actually done from some sort o= f=20 > process context. We run module handlers synchronously from the kldload(2= )=20 > syscall. Sure, but not when the module is loaded by the boot loader (note "can", not "will") > > You filled up a buffer somewhere... > Does uprintf() require the caller to flush the output to the tty somehow?= If=20 > so, that seems to be a bug. Nothing in the uprintf(9) manpage suggests t= hat=20 > the output should be manually flushed. I tried to read through the uprinf() code paths (into the tty layer etc). I didn't get very far, but I discovered two things: 1) The printf() code uses uninitialized or partially-initialized variables (grep pca) 2) There may be conditions in which tty_putchar() fails due to a buffer filling up, though I'm not sure they apply in this particular situation. Since uprintf() returns the number of characters actually written, this is easy to test. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no