Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Nov 2024 11:19:52 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        Mark Millard <marklmi@yahoo.com>
Cc:        "jah@freebsd.org" <jah@FreeBSD.org>,  dougm@freebsd.org, asomers@freebsd.org,  Mark Johnston <markj@FreeBSD.org>,  FreeBSD Current <freebsd-current@freebsd.org>,  Dimitry Andric <dim@FreeBSD.org>,  Guido Falsi <mad@madpilot.net>,  Yasuhiro Kimura <yasu@FreeBSD.org>, ports@freebsd.org
Subject:   Re: port binary dumping core on recent head in poudriere [tmpfs corruptions involving blocks of zeros that should not be all zeros]
Message-ID:  <865xoa2t6f.fsf@ltc.des.dev>
In-Reply-To: <3660625A-0EE8-40DA-A248-EC18C734718C@yahoo.com> (Mark Millard's message of "Tue, 26 Nov 2024 00:21:40 -0800")
References:  <aa597431-54a8-4cde-8d4f-b75040b59bae@madpilot.net> <f9e32784-226a-4e1e-a24b-62f5e6d3d765@madpilot.net> <E4616829-D2DE-4EAF-B971-1EDA8B447F13@FreeBSD.org> <7c9c3cf5-bbd1-4642-8d04-33aa07a4db02@madpilot.net> <9df256a8-c6ed-46d9-b955-fc2657c12d36@madpilot.net> <5c502054-7353-4a1e-8350-c403482e9c0d@madpilot.net> <a203a89f-2eb7-4220-8dfb-648cd46fc6bb@madpilot.net> <3127C3BA-FC93-4636-ADDB-89518DE9C60D@FreeBSD.org> <86ed2zsp6l.fsf@ltc.des.dev> <5f24a570-26e0-4c0a-817f-591a234fd07b@madpilot.net> <5918C6A1-8FDB-40CA-8C86-EB7B7BE75A2E@yahoo.com> <86ed2zc8r5.fsf@ltc.des.dev> <45098ccf-4dc6-426c-849a-c923805d6723@madpilot.net> <F64DB4E9-A210-4E1F-B333-C597F3DBED54@yahoo.com> <38658C0D-CA33-4010-BBE1-E68D253A3DF7@FreeBSD.org> <1004a753-9a3c-4aa2-bfa8-4a0c471fe3ea@madpilot.net> <D14FF56C-506F-4168-91BC-1F10937B943F@yahoo.com> <E77AF0C3-5210-41C7-B8B8-02A8E22DB23D@yahoo.com> <A2820AEA-AB92-425F-AE91-2AF9629B3020@yahoo.com> <0690CFB1-6A6D-4B63-916C-BAB7F6256000@yahoo.com> <3660625A-0EE8-40DA-A248-EC18C734718C@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Mark Millard <marklmi@yahoo.com> writes:
> From inside a bulk -i where I did a manual make command
> after it built and installed libsass.so.1.0.0 . The
> manual make produced a /wrkdirs/ :
> [...]
> So the original creation looks okay. But . . .
> [...]
> So: The later, staged copy is a bad copy. Both are in the
> tmpfs. So copying to the staging area makes a corrupted
> copy inside the same tmpfs. After that, further copies of
> staging's bad copy can be expected to be messed up.

This and the fact that it happens on 14 and 15 but not on 13 strongly
suggests an issue wth `copy_file_range(2)`, since `install(1)` in 14 and
15 (but not in 13) now uses `copy_file_range(2)` if at all possible.

My educated guess is that hole detection doesn't work reliably for files
that have had holes filled while memory-mapped, so `copy_file_range(2)`
thinks there is a hole where there isn't one and skips some of the data
when `install(1)` uses it to copy the library from `${WRKSRC}` to
`${STAGEDIR}`.  This may or may not be specific to tmpfs.

You may want to try applying the attached patch to your FreeBSD 14 and
15 jails.  It prevents `cp(1)` and `install(1)` from trying to use
`copy_file_range(2)`.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@FreeBSD.org


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-cp-install-disable-copy_file_range.patch

>From 18eb75139045c30609d93f6a138526d3288acbd9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= <des@FreeBSD.org>
Date: Tue, 26 Nov 2024 10:54:14 +0100
Subject: [PATCH] cp, install: disable copy_file_range.

---
 bin/cp/utils.c              | 2 +-
 usr.bin/xinstall/xinstall.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index cfbb2022caaf..c6a688235bf1 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -104,7 +104,7 @@ copy_file(const FTSENT *entp, int dne)
 	ssize_t wcount;
 	off_t wtotal;
 	int ch, checkch, from_fd, rval, to_fd;
-	int use_copy_file_range = 1;
+	int use_copy_file_range = 0;
 
 	fs = entp->fts_statp;
 	from_fd = to_fd = -1;
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index 2823a9040b7a..4ab0a6dd0de2 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -1194,6 +1194,7 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
 		err(EX_OSERR, "lseek: %s", to_name);
 
 #ifndef BOOTSTRAP_XINSTALL
+#if 0
 	/* Try copy_file_range() if no digest is requested */
 	if (digesttype == DIGEST_NONE) {
 		do {
@@ -1210,6 +1211,7 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
 		}
 		/* Fall back */
 	}
+#endif
 #endif
 	digest_init(&ctx);
 
-- 
2.46.0


--=-=-=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?865xoa2t6f.fsf>