public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top, David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH] util: In ASSERT(), use "fprintf(stderr, ...)" rather than err(...)
Date: Mon, 5 Aug 2024 18:12:27 +0200	[thread overview]
Message-ID: <20240805181210.3a9099e8@elisabeth> (raw)
In-Reply-To: <6db3262f-5ca5-4c8c-bfd4-bef636bf504a@redhat.com>

On Mon, 5 Aug 2024 17:52:06 +0200
Laurent Vivier <lvivier@redhat.com> wrote:

> On 05/08/2024 16:34, Stefano Brivio wrote:
> > On Mon,  5 Aug 2024 16:10:27 +0200
> > Laurent Vivier <lvivier@redhat.com> wrote:
> >   
> >> We use our own implementation of assert() because the glic implementation
> >> uses syscalls that aren't in our seccomp filter, see 7a8ed9459dfe
> >> ("Make assertions actually useful"). And we replaced it by an err(),
> >> followed by an abort() (that is also catched by seccomp).
> >> We don't have a coredump or a backtrace but we have at least the
> >> error message... only if logging is enabled.  
> > 
> > ...wait, err() should always end up somewhere (syslog, log file, or
> > stderr). If you pick stderr, and we closed stderr, then the error will
> > not be reported anywhere (or, possibly worse, on a socket that happens
> > to have number 2).
> > 
> > In which case are you losing messages?
> >   
> 
> Try something:
> 
> diff --git a/udp.c b/udp.c
> index a92014806a73..7e179d3b863b 100644
> --- a/udp.c
> +++ b/udp.c
> @@ -707,6 +707,8 @@ void udp_listen_sock_handler(const struct ctx *c, union epoll_ref ref,
>          if ((n = udp_sock_recv(c, ref.fd, events, mmh_recv)) <= 0)
>                  return;
> 
> +       ASSERT(0);
> +
>          /* We divide datagrams into batches based on how we need to send them,
>           * determined by udp_meta[i].tosidx.  To avoid either two passes through
>           * the array, or recalculating tosidx for a single entry, we have to
> 
> And then generate some UDP traffic.
> 
> This exits only with:
> 
> Bad system call
> 
> Oh, wait, I can see the error in the syslog... but it's not very intuitive as we have the 
> "Bad system call" displayed in the terminal.

Oops, this is an actual issue: if you run passt in foreground, then
err() should _also_ print to stderr, see commit bca0fefa32e0 ("conf,
passt: Make --stderr do nothing, and deprecate it")... but it doesn't.

That's because we set the log_runtime flag once we're ready (whether
we daemonised or not), and then we have:

	if (debug_print || !log_conf_parsed ||
	    (!log_runtime && (log_mask & LOG_MASK(LOG_PRI(pri))))) {
		(void)vfprintf(stderr, format, ap);
		if (newline && format[strlen(format)] != '\n')
			fprintf(stderr, "\n");
	}

See also https://archives.passt.top/passt-dev/ZnTUrhu8LNWi-krS@zatzit/.

Still, while we want to keep pasta usable, we should make sure we print
to stderr when passt is running in foreground. I'll send another
patch...

-- 
Stefano


  reply	other threads:[~2024-08-05 16:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05 14:10 [PATCH] util: In ASSERT(), use "fprintf(stderr, ...)" rather than err(...) Laurent Vivier
2024-08-05 14:34 ` Stefano Brivio
2024-08-05 15:52   ` Laurent Vivier
2024-08-05 16:12     ` Stefano Brivio [this message]
2024-08-06  0:27 ` David Gibson
2024-08-06  9:27   ` Laurent Vivier
2024-08-06 11:43     ` Stefano Brivio
2024-08-06 12:28     ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240805181210.3a9099e8@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).