Reproducible panic - Going nowhere without my init!

Konstantin Belousov kostikbel at gmail.com
Thu Oct 6 17:43:35 UTC 2016


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");


More information about the freebsd-stable mailing list