NetBSD Problem Report #58112

From www@netbsd.org  Thu Apr  4 17:15:07 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 255561A923C
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  4 Apr 2024 17:15:07 +0000 (UTC)
Message-Id: <20240404171505.3DB741A923D@mollari.NetBSD.org>
Date: Thu,  4 Apr 2024 17:15:05 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: daemonized rump conceals output on crash
X-Send-Pr-Version: www-1.0

>Number:         58112
>Category:       bin
>Synopsis:       daemonized rump conceals output on crash
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 04 17:20:01 +0000 2024
>Last-Modified:  Thu Apr 04 17:30:05 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, 8, ...
>Organization:
The TestBSD Rumpdation
>Environment:
growing more extreme weather as we toast the planet
>Description:
rumpuser_daemonize -- e.g., rump_server without -s -- sends all output to /dev/null:

    122 		fd = open(_PATH_DEVNULL, O_RDWR);
    123 		if (fd == -1) {
    124 			error = errno;
    125 			goto out;
    126 		}
    127 		dup2(fd, STDIN_FILENO);
    128 		dup2(fd, STDOUT_FILENO);
    129 		dup2(fd, STDERR_FILENO);
    130 		if (fd > STDERR_FILENO)
    131 			close(fd);

https://nxr.netbsd.org/xref/src/lib/librumpuser/rumpuser_daemonize.c?r=1.8#122

That means output from kernel printf also goes to /dev/null, because with librumpuser it is printed via putchar.

That means running a rump_server in, e.g., automatic tests, such as https://nxr.netbsd.org/xref/src/tests/rump/rumpkern/t_sp.sh?r=1.17, conceals all output when it crashes, as it has been frequently doing for the t_sp:sigsafe test.
>How-To-Repeat:
cd /usr/tests/rump/rumpkern && atf-run t_sp

repeat until it fails, in some appropriate environment where it fails, e.g.:

https://releng.netbsd.org/b5reports/i386/2024/2024.04.04.09.19.42/test.html#rump_rumpkern_t_sp_sigsafe
>Fix:
Maybe we could have environment variables RUMP_STDOUT=/path/to/outfile RUMP_STDERR=/path/to/errfile which rumpuser_daemonize_begin redirects fds 1 and 2 to, if set, so that the output is captured somewhere.

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58112 CVS commit: src/lib/librumpuser
Date: Thu, 4 Apr 2024 17:27:23 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Thu Apr  4 17:27:23 UTC 2024

 Modified Files:
 	src/lib/librumpuser: rumpuser_daemonize.c

 Log Message:
 rumpuser(3): New RUMP_STDOUT, RUMP_STDERR environment variables.

 If set, then when rump daemonizes, it opens the path in RUMP_STDOUT
 and redirects fd 1 to that (which mostly gets the kernel console
 output), and opens the path in RUMP_STDERR and redirects fd 2 to that
 (no idea what this gets but it's probably good to record if it ever
 gets anything).

 This will allow tests that rely on rump_server daemons to stash the
 output for diagnostics in case, e.g., the rump kernel crashes.

 PR bin/58112


 To generate a diff of this commit:
 cvs rdiff -u -r1.8 -r1.9 src/lib/librumpuser/rumpuser_daemonize.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58112 CVS commit: src/tests/rump/rumpkern
Date: Thu, 4 Apr 2024 17:27:32 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Thu Apr  4 17:27:32 UTC 2024

 Modified Files:
 	src/tests/rump/rumpkern: t_sp.sh

 Log Message:
 rumpkern/t_sp: Save stdout and stderr to report on failure.

 This is not very tidy at the moment, but it's an experiment using the
 approach in PR bin/58112, to diagnose why t_sp:sigsafe keeps failing
 intermittently.  If this works, perhaps can tidy it up and apply it
 to all the other tests that run rump_servers.


 To generate a diff of this commit:
 cvs rdiff -u -r1.17 -r1.18 src/tests/rump/rumpkern/t_sp.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.