From owner-freebsd-stable@freebsd.org Thu Oct 6 22:32:25 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 8C251BECE1D for ; Thu, 6 Oct 2016 22:32:25 +0000 (UTC) (envelope-from chuzzwassa@gmail.com) Received: from mail-oi0-x22e.google.com (mail-oi0-x22e.google.com [IPv6:2607:f8b0:4003:c06::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 493C09DF for ; Thu, 6 Oct 2016 22:32:25 +0000 (UTC) (envelope-from chuzzwassa@gmail.com) Received: by mail-oi0-x22e.google.com with SMTP id d132so38284914oib.2 for ; Thu, 06 Oct 2016 15:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=PqaYaSHIvkcXm5FLDwHOnlnYtVTHXWN2SevzN1wkckk=; b=FbM072DTAvXRoANRj/gJ0AE/IHChcds08BCkh7LFi+Hu1/wpdfKq0qt+pHkdkOiIad fbhThXGZZGC7DxakkZ9YK4G8l0ySrq1pqYCJArl5EbQzgM57qR574xt0T/j8MwZQDQUY 2JG+bukgR+mNlJ98Mka335+HfzM3JbA3mmaFj1tlC4bOgoO2drBisLVF+Qb0Is4ZbwiR sotb4VV9CsvipSaC65ynqf3KG2C1d+tk4rHtzhEr4hvo0UYxpd3Io4kV492qnfIA62cB xxM6NBuccfUB7gQqaWMMvd98umkS25tEe2bwTRRHQLldMLYAT+plZG3iM/zBpyLelqaY iaqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=PqaYaSHIvkcXm5FLDwHOnlnYtVTHXWN2SevzN1wkckk=; b=V7YB8G/DY3R+CGPmqObh0il1T58lYLh2NDCQHUazdmUn/ugRKZses8RSDWMtr7cbFm 8ZadC6w40FscqKChsQPH3dGtuJLdesY6XE79PYfrhX++P9hOFGcSVAQ6hEmJC4Ck4fyq LWqJRUsrWmKRaSL+xBMCeSqzayVEKx2ay5UDPiKNHO7Xw1iq/obwzU2hcQjMZLIYwjqm gP8IvcRIVT4kV8OHLn9GzZXidVO2czcQaEYYJS97WqiBar4YV2aWW3Tt3lysNOvfhEIQ R5ObllCZb+heLc3e1HKRbGgT8Jj2WRSR3CcMpu7jLy1+hOyxGFlaLElOYmQRKsUvz60J 8yzg== X-Gm-Message-State: AA6/9RmY26Yd/arknxWQ0bpmQbeL5H/1sPOZjoJq0LYzIH8tMDAh08Q8OwD7eO2+22aIh9hOiHhX0lzg8PCTQQ== X-Received: by 10.157.45.113 with SMTP id v104mr9784053ota.167.1475793144671; Thu, 06 Oct 2016 15:32:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.4.42 with HTTP; Thu, 6 Oct 2016 15:32:24 -0700 (PDT) From: Andy Farkas Date: Fri, 7 Oct 2016 08:32:24 +1000 Message-ID: Subject: Re: Reproducible panic - Going nowhere without my init! To: Konstantin Belousov , freebsd-stable@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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:32:25 -0000 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");