From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202508 header.b=qkoRqh1/; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id EC6955A0279 for ; Thu, 14 Aug 2025 07:36:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1755149770; bh=qxapQlm1mfeTMBIKGQZ8CNDfYHIpN84cK8ve47b4Y9I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qkoRqh1/HB7M+Gb2b5vfuXnf22zGaNuVTc8wfbmcdARiAEFG2zO6j+d0B6E3STAtD b1TGm/9hZp67y7WsHgqL+qzx+XPpUBSC/xI05NCVmcQZDmlRHWd44Hxy1Izej84qk2 qXZ7JaRz67QyloivksssnN85Y+9q5r6hSGp6YfazCQBiXVKYB2ENvmRURJN6sfN799 PYk8hIskbNrgD0HufVA8ibck1qX8XzqWF6eUfiyNtJ442E9xmq1sz4oiXHDh/Vgq+/ AdFZoEnwM6jMe0+k0aRXoqwvVG2LMNZCnRFFBrrJa6IQZLYnFB8aKxk/1d5e2iuD7q cwKAseG/KpZ0g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4c2YrB1QKDz4x5q; Thu, 14 Aug 2025 15:36:10 +1000 (AEST) Date: Thu, 14 Aug 2025 15:36:05 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] treewide: Flush pcap and log files, if used, before exiting Message-ID: References: <20250813164510.3382756-1-sbrivio@redhat.com> <20250814071255.3dfbd733@elisabeth> <20250814072419.643ec298@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="kcBVzzEfXUi2GZpx" Content-Disposition: inline In-Reply-To: <20250814072419.643ec298@elisabeth> Message-ID-Hash: WR6M2L34XK6LXR2UFQNGBZZHYXYCQJC4 X-Message-ID-Hash: WR6M2L34XK6LXR2UFQNGBZZHYXYCQJC4 X-MailFrom: dgibson@gandalf.ozlabs.org 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, Paul Holzinger 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: --kcBVzzEfXUi2GZpx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 14, 2025 at 07:24:19AM +0200, Stefano Brivio wrote: > On Thu, 14 Aug 2025 07:12:55 +0200 > Stefano Brivio wrote: >=20 > > On Thu, 14 Aug 2025 14:10:20 +1000 > > David Gibson wrote: > >=20 > > > On Wed, Aug 13, 2025 at 06:45:05PM +0200, Stefano Brivio wrote: =20 > > > > 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 issu= es > > > > with this beauty: =20 > > >=20 > > > I think the problems are more introduced by the previous patch > > > d0006fa784a7 ("treewide: use _exit() over exit()"). =20 > >=20 > > Oops, right. > >=20 > > > >=20 > > > > while true; do ./pasta --trace -l /tmp/pasta.log -p /tmp/pasta.pc= ap --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 > > > >=20 > > > > ...flush files and pcap if we're using them. Ignore fsync() errors = for > > > > the log file as we obviously can't reliably log them. > > > >=20 > > > > Signed-off-by: Stefano Brivio =20 > > >=20 > > > Hmmmmm. > > >=20 > > > 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. =20 > >=20 > > 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. > >=20 > > So, strictly speaking, at least for correctness, we should actually > > keep those fflush() calls plus the ones I'm adding here, even with > > exit(). >=20 > Ah, wait, sorry, I just double checked and starting from Issue 7 of > POSIX (referring to _exit() and _Exit()): >=20 > Austin Group Interpretation 1003.1-2001 #031 is applied, separating > these functions from the exit() function. >=20 > and: >=20 > 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. --=20 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 --kcBVzzEfXUi2GZpx Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmiddcQACgkQzQJF27ox 2Gd3yw/8C2tC1ENoyz9mIdGg58Um2jkmoz2JHJksGDus+g7Z8nzabGDmKJuSFo3r x230MQ1a3JdPw27vLyvcqlGD0g5eoufxczpDYkBfZre9E3RC9i1HiyhyBfKuFzKH Tl/+DrmfecTbMB69lv7BukU4vgsmn0MgxWvJRWdzrKLwjGWS1/aLCF5Es0Ijp98w kBK5HKs0dv9DIUFYd2u7SwJlFiwoYYopIkTueYpiXundSleGcIdVe8avaHBRt17d zoQC3Msf/9H3fopdKA50dLaq+0RDNSvpImjIZeyq9tq+SB6XQa96MXG3ZA0egmKh DHtk6wC5PD+f230MMGLpfKR2UHiBf0YahxXIhexhAoRFw1Ionyv3/Ek8WDwAK20q SuLuq97IIxhwlxJt8PN7NS25zH0wChdFPp11KNx52K2X/Mw0dPHlWncGhMUNN355 i7ze1zVLltLhuvNZRx1MjjlKlh2QMBnwNCdVwknJk7t2HYYeJzX3Lx/39ZYQh7l4 S3c1Qrl4VBronHMiXpmIAls7IEUvbjEtw2gum54DLBo3wKc9Ps4sJ3H04c8OEFY2 lOAUnUHyPG9pbo/V6Bzhtp4eaN/2sRIqiiuJlWJujNJiIH+IA1FMoQ4+WlClJeFf jy9HsmpunxexGtgnKCs9XdxROqryTiZ3sJzQgSEK+Pjr9YqWdck= =ZXS/ -----END PGP SIGNATURE----- --kcBVzzEfXUi2GZpx--