public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH] Fix PR pch/68758
Date: Wed, 27 Jan 2016 12:52:00 -0000	[thread overview]
Message-ID: <56A8BD81.2040000@suse.cz> (raw)

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

Hello.

As mentioned in: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68758#c5, I consider
more logic to encapsulate valgrind annotation magic within a ENABLE_VALGRIND_ANNOTATIONS
macro rather than ENABLE_VALGRIND_CHECKING.

With patch applied, ggc invalid reads/writes, reported by valgrind tool, are gone.
The patch can survive regression tests and bootstrap on x86_64-linux-gnu?

Ready for trunk?
Thanks,
Martin

[-- Attachment #2: 0001-Fix-PR-pch-68758.patch --]
[-- Type: text/x-patch, Size: 2039 bytes --]

From bfa1e418c8039f8f81047fc1c60c185a95a4deca Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 6 Jan 2016 13:29:33 +0100
Subject: [PATCH] Fix PR pch/68758.

gcc/ChangeLog:

2016-01-06  Martin Liska  <mliska@suse.cz>

	PR pch/68758
	* ggc-common.c (gt_pch_save): Use ENABLE_VALGRIND_ANNOTATIONS macro
	instead of ENABLE_VALGRIND_CHECKING.
---
 gcc/ggc-common.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index c919ba8..9b291aa 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -492,7 +492,7 @@ gt_pch_save (FILE *f)
 
   ggc_pch_prepare_write (state.d, state.f);
 
-#if defined ENABLE_VALGRIND_CHECKING && defined VALGRIND_GET_VBITS
+#if defined ENABLE_VALGRIND_ANNOTATIONS && defined VALGRIND_GET_VBITS
   vec<char> vbits = vNULL;
 #endif
 
@@ -504,7 +504,7 @@ gt_pch_save (FILE *f)
 	  this_object_size = state.ptrs[i]->size;
 	  this_object = XRESIZEVAR (char, this_object, this_object_size);
 	}
-#if defined ENABLE_VALGRIND_CHECKING && defined VALGRIND_GET_VBITS
+#if defined ENABLE_VALGRIND_ANNOTATIONS && defined VALGRIND_GET_VBITS
       /* obj might contain uninitialized bytes, e.g. in the trailing
 	 padding of the object.  Avoid warnings by making the memory
 	 temporarily defined and then restoring previous state.  */
@@ -561,7 +561,7 @@ gt_pch_save (FILE *f)
 			    state.ptrs[i]->note_ptr_fn == gt_pch_p_S);
       if (state.ptrs[i]->note_ptr_fn != gt_pch_p_S)
 	memcpy (state.ptrs[i]->obj, this_object, state.ptrs[i]->size);
-#if defined ENABLE_VALGRIND_CHECKING && defined VALGRIND_GET_VBITS
+#if defined ENABLE_VALGRIND_ANNOTATIONS && defined VALGRIND_GET_VBITS
       if (__builtin_expect (get_vbits == 1, 0))
 	{
 	  (void) VALGRIND_SET_VBITS (state.ptrs[i]->obj, vbits.address (),
@@ -575,7 +575,7 @@ gt_pch_save (FILE *f)
 	}
 #endif
     }
-#if defined ENABLE_VALGRIND_CHECKING && defined VALGRIND_GET_VBITS
+#if defined ENABLE_VALGRIND_ANNOTATIONS && defined VALGRIND_GET_VBITS
   vbits.release ();
 #endif
 
-- 
2.7.0


             reply	other threads:[~2016-01-27 12:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-27 12:52 Martin Liška [this message]
2016-01-27 13:04 ` Richard Biener

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=56A8BD81.2040000@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.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).