From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 9A78F5A004F for ; Mon, 05 Aug 2024 18:12:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722874354; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+lFsmMD97G67YB9SZgZRGnAC8SELyL6smBJSsAsDKQk=; b=HsDP2L4AVyB8Dep52qv7/oalWF0r2UTn+8pimWHSges4CqBOHnHGni9WLxf9YpmHXMIQdj AfK7w1fSYVHrffS7Do0H/NEwjfS5SJlo4s6mLjHyj0MwLkTPE/spWKAQ/XusFNQZfOa0s8 LTzJOG1PyHYM3/xIRbXreac9kbaQN/k= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-0lzvZY0uPoePjlKQfpkqlg-1; Mon, 05 Aug 2024 12:12:33 -0400 X-MC-Unique: 0lzvZY0uPoePjlKQfpkqlg-1 Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-1fc4fcaa2e8so107548325ad.1 for ; Mon, 05 Aug 2024 09:12:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722874352; x=1723479152; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+lFsmMD97G67YB9SZgZRGnAC8SELyL6smBJSsAsDKQk=; b=Phhy6m5hFvmKWozKw2aOca5ba9eUhwq+X4MtlySfp7OmGyRRA5Ej8IECKCLm9133Fv F4a6gQcYBosG4dilOqM7TACZwG+HVJl6YRqPilxClkhoI+P9GYKXfu54XKbs9+lSivde WIlJbx/MX7lTrjf5rQynRBzb1mvrsvkMhJ7hhbhcJQifqNljokXCvZaUsqV0R6OIgCo/ /1HqIyjUzZdTtmt24+6jemLKhqieDTPd1FUvQMCQyulZcNZERS4PlgIb/xqq+bo961Fz NrjUfLegm9kTVqSkp556aXbkRUrWpF5XTNy1XbBkehcczjKtSdLXjkCVTpXb0IExDpjO qWwg== X-Gm-Message-State: AOJu0Yzb1mukxuua4ntXyqahVn/Ouf+U9gqWhQl1RDbORwdje6N4droK O/AvhCaGG3Pmk4X/hs6hza8rH4U1+UWlxANC8M8itHy+ksb9vdcHR6Il/YEpZkVRm7vaRKQAZz2 btbpxE3Xsyd+4XLNSod8dGGKcwFcr+e6l8EAvcqql6sWjKopg6w== X-Received: by 2002:a17:902:ea0c:b0:1fc:7309:9125 with SMTP id d9443c01a7336-1ff57302986mr155270095ad.34.1722874352039; Mon, 05 Aug 2024 09:12:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaYAdNo8wXvZ+FkF9sIPr+GTLsv3YlxLwDjMLx0vl3Q43AbtLyWcbDlUQjsxNrC1WK7BCCMA== X-Received: by 2002:a17:902:ea0c:b0:1fc:7309:9125 with SMTP id d9443c01a7336-1ff57302986mr155269905ad.34.1722874351683; Mon, 05 Aug 2024 09:12:31 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff592ad9d9sm69316495ad.281.2024.08.05.09.12.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 09:12:30 -0700 (PDT) Date: Mon, 5 Aug 2024 18:12:27 +0200 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH] util: In ASSERT(), use "fprintf(stderr, ...)" rather than err(...) Message-ID: <20240805181210.3a9099e8@elisabeth> In-Reply-To: <6db3262f-5ca5-4c8c-bfd4-bef636bf504a@redhat.com> References: <20240805141027.1502569-1-lvivier@redhat.com> <20240805163423.58f602f7@elisabeth> <6db3262f-5ca5-4c8c-bfd4-bef636bf504a@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: K66NKDMRF6XNTIKOR2QEXGC73XSB4XCV X-Message-ID-Hash: K66NKDMRF6XNTIKOR2QEXGC73XSB4XCV X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Mon, 5 Aug 2024 17:52:06 +0200 Laurent Vivier wrote: > On 05/08/2024 16:34, Stefano Brivio wrote: > > On Mon, 5 Aug 2024 16:10:27 +0200 > > Laurent Vivier 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