This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/33796] valgrind error with -O2 for linux kernel code
- From: "bonzini at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Oct 2007 13:21:29 -0000
- Subject: [Bug rtl-optimization/33796] valgrind error with -O2 for linux kernel code
- References: <bug-33796-9596@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from bonzini at gnu dot org 2007-10-31 13:21 -------
Reopening and marking as enhancement.
A patch like this should work:
Index: sparseset.c
===================================================================
--- sparseset.c (revision 129768)
+++ sparseset.c (working copy)
@@ -21,6 +21,18 @@ along with GCC; see the file COPYING3.
#include "libiberty.h"
#include "sparseset.h"
+#ifdef ENABLE_VALGRIND_CHECKING
+# ifdef HAVE_VALGRIND_MEMCHECK_H
+# include <valgrind/memcheck.h>
+# elif defined HAVE_MEMCHECK_H
+# include <memcheck.h>
+# else
+# include <valgrind.h>
+# endif
+#else
+/* Avoid #ifdef:s when we can help it. */
+#define VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(x, y)
+#endif
/* Allocate and clear a n_elms SparseSet. */
@@ -33,6 +45,8 @@ sparseset_alloc (SPARSESET_ELT_TYPE n_el
sparseset set = (sparseset) xmalloc (n_bytes);
set->dense = &(set->elms[0]);
set->sparse = &(set->elms[n_elms]);
+ VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE
+ (set->sparse, n_elms * sizeof (SPARSESET_ELT_TYPE));
set->size = n_elms;
sparseset_clear (set);
return set;
but only if the compiler is compiled with --enable-checking=valgrind or
--enable-checking=yes,valgrind. There are data structures that *rely* on safe
uninitialized data reads for speed, this is one of them.
--
bonzini at gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|RESOLVED |REOPENED
GCC target triplet|x86_64-linux-gnu |{i86,x86_64}-linux-gnu
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33796