From owner-freebsd-stable@freebsd.org Thu Oct 6 22:56:02 2016 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEE4CBED2E2 for ; Thu, 6 Oct 2016 22:56:02 +0000 (UTC) (envelope-from graham@menhennitt.com.au) Received: from homiemail-a126.g.dreamhost.com (sub5.mail.dreamhost.com [208.113.200.129]) (using TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CCE563B2 for ; Thu, 6 Oct 2016 22:56:02 +0000 (UTC) (envelope-from graham@menhennitt.com.au) Received: from homiemail-a126.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a126.g.dreamhost.com (Postfix) with ESMTP id DB5486000541F for ; Thu, 6 Oct 2016 15:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=menhennitt.com.au; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s= menhennitt.com.au; bh=NAUpNZR8t3B4BO/B9EMeaWKdx1o=; b=Bsb/f25hkO GteY66fXaCM74NVu/K9HYMlGFf9vi64CUqCZpdp3fndIm9J59Um0cEkOiZaqakgX k+BR+AfC/nqTqN40hKYzHyfWT9Z8QRrTxw6lfTW70YkQWle7oEN6T9QF562qNN9m Nm1u4sKLLcPII6QPy3L8JvDwDxEWEHBng= Received: from [137.237.172.92] (unknown [192.160.117.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: graham@menhennitt.com.au) by homiemail-a126.g.dreamhost.com (Postfix) with ESMTPSA id 2D6046000541A for ; Thu, 6 Oct 2016 15:55:54 -0700 (PDT) Subject: Re: Reproducible panic - Going nowhere without my init! To: freebsd-stable@freebsd.org References: From: Graham Menhennitt Message-ID: Date: Fri, 7 Oct 2016 09:55:48 +1100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Oct 2016 22:56:03 -0000 Let me preface this by saying that I know nothing about this particular bit of code, but... As a general rule, I would question the use of gettimeofday() while panicing. At that stage, everything could have already gone down the plug hole. That said, it already calls sleep(), so maybe that uses the same gettimeofday() call internally. In which case, please ignore this comment. Graham On 7/10/2016 9:32 AM, Andy Farkas wrote: > With your latest patch applied, I ran through my procedure more > than a dozen times and no panics! > > Any explanation why sleep(STALL_TIMEOUT) as apposed to a > bunch of sleep(1)'s tickles the panic? > > Also, it is definitely not sleeping for 30 seconds. I guess some > event interrupts the sleep loop? > > Thanks heaps for your time and effort, > > -andyf > > %%% > Please try the following patch. > > diff --git a/sbin/init/init.c b/sbin/init/init.c > index bda86b5..25ac2bd 100644 > --- a/sbin/init/init.c > +++ b/sbin/init/init.c > @@ -870,6 +870,7 @@ single_user(void) > sigset_t mask; > const char *shell; > char *argv[2]; > + struct timeval tv, tn; > #ifdef SECURE > struct ttyent *typ; > struct passwd *pp; > @@ -884,8 +885,13 @@ single_user(void) > if (Reboot) { > /* Instead of going single user, let's reboot the machine */ > sync(); > - reboot(howto); > - _exit(0); > + if (reboot(howto) == -1) { > + emergency("reboot(%#x) failed, %s", howto, > + strerror(errno)); > + _exit(1); /* panic and reboot */ > + } > + warning("reboot(%#x) returned", howto); > + _exit(0); /* panic as well */ > } > > shell = get_shell(); > @@ -1002,7 +1008,14 @@ single_user(void) > * reboot(8) killed shell? > */ > warning("single user shell terminated."); > - sleep(STALL_TIMEOUT); > + gettimeofday(&tv, NULL); > + tn = tv; > + tv.tv_sec += STALL_TIMEOUT; > + while (tv.tv_sec > tn.tv_sec || (tv.tv_sec == > + tn.tv_sec && tv.tv_usec > tn.tv_usec)) { > + sleep(1); > + gettimeofday(&tn, NULL); > + } > _exit(0); > } else { > warning("single user shell terminated, restarting"); > _______________________________________________ > freebsd-stable@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-stable > To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"