public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/98912] valgrind error in default_elf_asm_output_ascii
Date: Tue, 02 Feb 2021 09:25:44 +0000	[thread overview]
Message-ID: <bug-98912-4-6zs2qV9987@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98912-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98912

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> Well, lto_section is 8 byte long struct containing 2 ushort fields, 1 uchar,
> one byte padding (on most hosts) and one ushort field.
> So bet valgrind is complaining about streaming the padding...

I bet it's complaining about the padding.
Please test the following debugging patch:

diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 405f3bfc56c..d96a7ee3ec8 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -2672,6 +2672,10 @@ produce_lto_section ()
   lto_section s
     = { LTO_major_version, LTO_minor_version, slim_object, 0 };
   s.set_compression (compression);
+  char *ptr = (char *)&s;
+  for (unsigned i = 0; i < sizeof s; i++)
+    fprintf (stderr, "v[%d]=%d\n", i, ptr[i]);
+  fprintf (stderr, "\n");
   lto_write_data (&s, sizeof s);
   lto_end_section ();
   destroy_output_block (ob);

with GCC 10 the object is constructed in the following way:

  MEM <char[4]> [(struct lto_section *)&s + 2B] = {};
  s.major_version = 9;
  s.slim_object = prephitmp_911;
  s.flags = 1;

and that covers all bytes in the struct.

  parent reply	other threads:[~2021-02-02  9:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 10:44 [Bug lto/98912] New: " dcb314 at hotmail dot com
2021-02-01 14:47 ` [Bug lto/98912] " marxin at gcc dot gnu.org
2021-02-01 14:52 ` jakub at gcc dot gnu.org
2021-02-01 14:58 ` dcb314 at hotmail dot com
2021-02-02  9:25 ` marxin at gcc dot gnu.org [this message]
2021-02-02  9:31 ` jakub at gcc dot gnu.org
2021-02-03  9:54 ` marxin at gcc dot gnu.org
2021-02-03 12:19 ` cvs-commit at gcc dot gnu.org
2021-02-03 12:19 ` marxin at gcc dot gnu.org

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=bug-98912-4-6zs2qV9987@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).