public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Paul Holzinger <pholzing@redhat.com>
Subject: Re: [PATCH] treewide: Flush pcap and log files, if used, before exiting
Date: Thu, 14 Aug 2025 15:36:05 +1000	[thread overview]
Message-ID: <aJ11xWwJiSqxAqrS@zatzit> (raw)
In-Reply-To: <20250814072419.643ec298@elisabeth>

[-- Attachment #1: Type: text/plain, Size: 2792 bytes --]

On Thu, Aug 14, 2025 at 07:24:19AM +0200, Stefano Brivio wrote:
> On Thu, 14 Aug 2025 07:12:55 +0200
> Stefano Brivio <sbrivio@redhat.com> wrote:
> 
> > On Thu, 14 Aug 2025 14:10:20 +1000
> > David Gibson <david@gibson.dropbear.id.au> wrote:
> > 
> > > On Wed, Aug 13, 2025 at 06:45:05PM +0200, Stefano Brivio wrote:  
> > > > I didn't imagine that occasionally truncated pcap and log files, as a
> > > > result of commit a9d63f91a59a ("passt-repair: use _exit() over
> > > > return"), would be such a big deal, until I tried to debug TCP issues
> > > > with this beauty:    
> > > 
> > > I think the problems are more introduced by the previous patch
> > > d0006fa784a7 ("treewide: use _exit() over exit()").  
> > 
> > Oops, right.
> > 
> > > > 
> > > >   while true; do ./pasta --trace -l /tmp/pasta.log -p /tmp/pasta.pcap --config-net -t 5555 -- socat TCP-LISTEN:5555 OPEN:/tmp/large.rcv,trunc & (sleep 0.3; socat -T2 OPEN:large.bin TCP:88.198.0.164:5555; ); wait; diff large.bin /tmp/large.rcv || break; done
> > > > 
> > > > ...flush files and pcap if we're using them. Ignore fsync() errors for
> > > > the log file as we obviously can't reliably log them.
> > > > 
> > > > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>    
> > > 
> > > Hmmmmm.
> > > 
> > > I mean, yes, AFAICT this patch will address the immediate problem.
> > > But between this and 081df67d1fb2 ("conf: flush stdout before early
> > > exit") it seems more and more to me that _exit() just isn't what we
> > > want.  Basically the assertion in d0006fa784a7 that "no exit handlers
> > > are needed" doesn't really seem to be true.  
> > 
> > It was a wrong assumption but just for a couple of cases, and mind that
> > exit() doesn't give you any guarantee anyway. While glibc might
> > guarantee those flushes, we're not just building against glibc.
> > 
> > So, strictly speaking, at least for correctness, we should actually
> > keep those fflush() calls plus the ones I'm adding here, even with
> > exit().
> 
> Ah, wait, sorry, I just double checked and starting from Issue 7 of
> POSIX (referring to _exit() and _Exit()):
> 
>   Austin Group Interpretation 1003.1-2001 #031 is applied, separating
>   these functions from the exit() function.
> 
> and:
> 
>   The exit() function shall then flush all open streams with unwritten
>   buffered data and close all open streams.

Yeah, I was thinking that sounded wrong.  I wasn't sure where it would
be specified, but to not flush stdio streams on normal program exit
(i.e. exit(3)) would be Really Weird.

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-08-14  5:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 16:45 [PATCH] treewide: Flush pcap and log files, if used, before exiting Stefano Brivio
2025-08-14  4:10 ` David Gibson
2025-08-14  5:12   ` Stefano Brivio
2025-08-14  5:24     ` Stefano Brivio
2025-08-14  5:36       ` David Gibson [this message]
2025-08-15  5:50     ` 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=aJ11xWwJiSqxAqrS@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=pholzing@redhat.com \
    --cc=sbrivio@redhat.com \
    /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).