From owner-freebsd-stable@freebsd.org Thu Oct 6 17:43:35 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 203F3BECF65 for ; Thu, 6 Oct 2016 17:43:35 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BFD877D4 for ; Thu, 6 Oct 2016 17:43:34 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u96HhT4e032772 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Thu, 6 Oct 2016 20:43:29 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u96HhT4e032772 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u96HhT8B032771; Thu, 6 Oct 2016 20:43:29 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 6 Oct 2016 20:43:29 +0300 From: Konstantin Belousov To: Andy Farkas Cc: freebsd-stable@freebsd.org Subject: Re: Reproducible panic - Going nowhere without my init! Message-ID: <20161006174329.GR38409@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home 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 17:43:35 -0000 On Thu, Oct 06, 2016 at 06:31:59PM +1000, Andy Farkas wrote: > Reverted your patch then changed line 1011 of init.c to _exit(97): > > --- init.c-orig 2016-10-05 18:52:24.022910000 +1000 > +++ init.c 2016-10-06 17:02:33.714624000 +1000 > @@ -1008,7 +1008,7 @@ > */ > warning("single user shell terminated."); > sleep(STALL_TIMEOUT); > - _exit(0); > + _exit(97); > } else { > warning("single user shell terminated, restarting"); > return (state_func_t) single_user; > > ...and got a panic that showed "exit 97": http://imgur.com/xonPwxR > > I think that kern_reboot() is not being called somehow. > kern_reboot() is the only place rebooting = 1; is executed. > > "init died (signal 0, exit 97) > panic: Going nowhere without my init!" > > can only happen if rebooting = 0 in kern_exit.c exit1(). > > Another tell that kern_reboot() has not been called is "cpuid = 3" > because the first thing kern_reboot() does is bind to CPU 0. > > Why is kern_reboot() being skipped? I have no idea. > > Anything more I can do to help? Do you want a core dump? > 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");