public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Aleksei Vetrov <vvvvvv@google.com>
Cc: elfutils-devel@sourceware.org
Subject: Re: ☠ Buildbot (GNU Toolchain): elfutils - failed test (failure) (master)
Date: Sun, 16 Oct 2022 18:26:39 +0200	[thread overview]
Message-ID: <Y0wwv6SPuy5EyqYX@wildebeest.org> (raw)
In-Reply-To: <20221016154722.971AD385841F@sourceware.org>

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

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

[-- Attachment #2: 0001-tests-Check-lseek-read-and-malloc-results-with-corre.patch --]
[-- Type: text/x-diff, Size: 2879 bytes --]

From 72860bfdca5286399837080d53ba297bf72c56b3 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
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 <mark@klomp.org>
---
 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  <mark@klomp.org>
+
+	* dwfl-report-offline-memory.c (main): Check lseek, read and malloc
+	results with correct types.
+
 2022-09-13  Aleksei Vetrov  <vvvvvv@google.com>
 
 	* 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


[-- Attachment #3: 0001-tests-include-config.h-first.patch --]
[-- Type: text/x-diff, Size: 1376 bytes --]

From 2a4ce08fafcf76d866ae5f6b394389d8d93aa0cb Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
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 <mark@klomp.org>
---
 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  <mark@klomp.org>
+
+	* dwfl-report-offline-memory.c: Include config.h first.
+
 2022-10-16  Mark Wielaard  <mark@klomp.org>
 
 	* 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 <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <config.h>
+
+#include <assert.h>
 #include <fcntl.h>
 #include <locale.h>
 #include <stdio.h>
-- 
2.30.2


  reply	other threads:[~2022-10-16 16:26 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-16 15:47 builder
2022-10-16 16:26 ` Mark Wielaard [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-01-14  2:51 builder
2022-12-21 18:22 builder
2022-12-19 23:56 builder
2022-12-12 14:31 builder
2022-11-28 13:30 builder
2022-11-04 22:29 builder
2022-11-03 15:27 builder
2022-11-02 13:39 builder
2022-11-02 14:19 ` Mark Wielaard
2022-11-02  1:15 builder
2022-11-02 12:06 ` Mark Wielaard
2022-11-01 21:28 builder
2022-10-31 13:51 builder
2022-10-27 19:25 builder
2022-10-17 14:59 builder
2022-10-17  9:08 builder
2022-10-17 10:26 ` Mark Wielaard
2022-10-17 11:02   ` Frank Ch. Eigler
2022-10-17 14:09     ` Frank Ch. Eigler
2022-10-16 21:02 builder
2022-10-13 16:51 builder
2022-09-14 19:36 builder
2022-07-31 23:54 builder
2022-08-01  0:09 ` Mark Wielaard
2022-08-01  9:13   ` Mark Wielaard
2022-05-28  9:15 builder
2022-05-28  9:35 ` Mark Wielaard
2022-05-28  9:43   ` Mark Wielaard
2022-06-02 15:44     ` Mark Wielaard
2022-05-27 16:02 builder
2022-05-27 22:30 ` Mark Wielaard
2022-05-28  2:34   ` Frank Ch. Eigler
2022-05-28  9:04     ` Mark Wielaard
2022-05-14 15:34 builder
2022-05-14 16:40 ` Mark Wielaard
2022-05-14 14:42 builder
2022-05-04 15:34 builder
2022-05-04 17:44 ` Mark Wielaard
2022-04-23 13:19 builder
2022-04-23  1:19 builder
2022-04-23  1:31 ` Mark Wielaard
2022-04-19  9:05 builder
2022-04-19  9:28 ` Mark Wielaard

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=Y0wwv6SPuy5EyqYX@wildebeest.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    --cc=vvvvvv@google.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).