From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 1C02A3858D3C for ; Sun, 16 Oct 2022 16:26:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1C02A3858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x0e.wildebeest.org [172.31.17.144]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 161353000913; Sun, 16 Oct 2022 18:26:40 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id E2FD52E8028B; Sun, 16 Oct 2022 18:26:39 +0200 (CEST) Date: Sun, 16 Oct 2022 18:26:39 +0200 From: Mark Wielaard To: Aleksei Vetrov Cc: elfutils-devel@sourceware.org Subject: Re: =?utf-8?B?4pigIEJ1aWxkYm8=?= =?utf-8?Q?t?= (GNU Toolchain): elfutils - failed test (failure) (master) Message-ID: References: <20221016154722.971AD385841F@sourceware.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="cT0MBR2VK9wJ1KiR" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221016154722.971AD385841F@sourceware.org> X-Spam-Status: No, score=-3039.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --cT0MBR2VK9wJ1KiR Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit There is a run-debuginfod-federation-metrics.sh failure that must be unrelated. It is an odd crash in the shell script wait statement? But there are also a few failures compiling the new testcase: In file included from /usr/include/features.h:490, from /usr/include/assert.h:35, from dwfl-report-offline-memory.c:18: In function ‘read’, inlined from ‘main’ at dwfl-report-offline-memory.c:68:23: /usr/include/bits/unistd.h:38:10: error: ‘__read_alias’ specified size 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] 38 | return __glibc_fortify (read, __nbytes, sizeof (char), | ^~~~~~~~~~~~~~~ /usr/include/bits/unistd.h: In function ‘main’: /usr/include/bits/unistd.h:26:16: note: in a call to function ‘__read_alias’ declared with attribute ‘access (write_only, 2, 3)’ 26 | extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf, | ^~~~~~~~~~ cc1: all warnings being treated as errors make[2]: *** [Makefile:2461: dwfl-report-offline-memory.o] Error 1 This seems technically correct since we use the wrong types size_t vs off_t and ssize_t and don't check the results from lseek, read and malloc. Patch to fix that attached. And there is an error on 32bit systems: tests/dwfl-report-offline-memory contains non-lfs symbols: lseek open Fix that by including config.h earlier. Cheers, Mark --cT0MBR2VK9wJ1KiR Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-tests-Check-lseek-read-and-malloc-results-with-corre.patch" Content-Transfer-Encoding: 8bit >From 72860bfdca5286399837080d53ba297bf72c56b3 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 16 Oct 2022 18:02:46 +0200 Subject: [PATCH] tests: Check lseek, read and malloc results with correct types in test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling dwfl-report-offline-memory.c on some systems (latest gcc/glibc and --enable-sanitize-undefined) we might get: In file included from /usr/include/features.h:490, from /usr/include/assert.h:35, from dwfl-report-offline-memory.c:18: In function ‘read’, inlined from ‘main’ at dwfl-report-offline-memory.c:68:23: /usr/include/bits/unistd.h:38:10: error: ‘__read_alias’ specified size 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] 38 | return __glibc_fortify (read, __nbytes, sizeof (char), | ^~~~~~~~~~~~~~~ /usr/include/bits/unistd.h: In function ‘main’: /usr/include/bits/unistd.h:26:16: note: in a call to function ‘__read_alias’ declared with attribute ‘access (write_only, 2, 3)’ 26 | extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf, | ^~~~~~~~~~ cc1: all warnings being treated as errors make[2]: *** [Makefile:2461: dwfl-report-offline-memory.o] Error 1 Fix by using the correct types and checking all return values. Signed-off-by: Mark Wielaard --- tests/ChangeLog | 5 +++++ tests/dwfl-report-offline-memory.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index 6ac2c1e8..d07a910e 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2022-10-16 Mark Wielaard + + * dwfl-report-offline-memory.c (main): Check lseek, read and malloc + results with correct types. + 2022-09-13 Aleksei Vetrov * Makefile.am (check_PROGRAMS): Add dwfl-report-offline-memory. diff --git a/tests/dwfl-report-offline-memory.c b/tests/dwfl-report-offline-memory.c index 837aca5e..81fa136f 100644 --- a/tests/dwfl-report-offline-memory.c +++ b/tests/dwfl-report-offline-memory.c @@ -62,10 +62,14 @@ main (int argc, char **argv) int fd = open (fname, O_RDONLY); if (fd < 0) error (-1, 0, "can't open file %s: %s", fname, strerror (errno)); - size_t size = lseek (fd, 0, SEEK_END); + off_t size = lseek (fd, 0, SEEK_END); + if (size < 0) + error (-1, 0, "can't lseek file %s: %s", fname, strerror (errno)); lseek (fd, 0, SEEK_SET); char *data = malloc (size); - size_t bytes_read = read (fd, data, size); + if (data == NULL) + error (-1, 0, "can't malloc: %s", strerror (errno)); + ssize_t bytes_read = read (fd, data, size); assert (bytes_read == size); close (fd); -- 2.30.2 --cT0MBR2VK9wJ1KiR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-tests-include-config.h-first.patch" >From 2a4ce08fafcf76d866ae5f6b394389d8d93aa0cb Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 16 Oct 2022 18:23:06 +0200 Subject: [PATCH] tests: include config.h first. Otherwise some symbols (lseek, open) might not get the 64bit offset variants because they don't pick up _FILE_OFFSET_BITS. Signed-off-by: Mark Wielaard --- tests/ChangeLog | 4 ++++ tests/dwfl-report-offline-memory.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index d07a910e..0ea1df3d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2022-10-16 Mark Wielaard + + * dwfl-report-offline-memory.c: Include config.h first. + 2022-10-16 Mark Wielaard * dwfl-report-offline-memory.c (main): Check lseek, read and malloc diff --git a/tests/dwfl-report-offline-memory.c b/tests/dwfl-report-offline-memory.c index 81fa136f..e6cb0a51 100644 --- a/tests/dwfl-report-offline-memory.c +++ b/tests/dwfl-report-offline-memory.c @@ -15,8 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include #include + +#include #include #include #include -- 2.30.2 --cT0MBR2VK9wJ1KiR--