This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] condition decision based on uninitialized memory
- From: Martin LiÅka <mliska at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 05 Dec 2014 13:36:07 +0100
- Subject: [PATCH] condition decision based on uninitialized memory
- Authentication-results: sourceware.org; auth=none
Hello.
I've just spent some time hunting memory leaks related to my isolated branch.
Valgrind reports many following errors:
==13612== Conditional jump or move depends on uninitialised value(s)
==13612== at 0xAC72A4: sparseset_bit_p (sparseset.h:147)
==13612== by 0xAC72A4: sparseset_and_compl(sparseset_def*, sparseset_def*, sparseset_def*) (sparseset.c:190)
==13612== by 0x9B296C: process_bb_lives(basic_block_def*, int&, bool) (lra-lives.c:885)
==13612== by 0x9B394A: lra_create_live_ranges_1(bool, bool) (lra-lives.c:1264)
==13612== by 0x9B426F: lra_create_live_ranges(bool, bool) (lra-lives.c:1329)
==13612== by 0x99B4A3: lra(_IO_FILE*) (lra.c:2350)
==13612== by 0x959B79: do_reload (ira.c:5391)
==13612== by 0x959B79: (anonymous namespace)::pass_reload::execute(function*) (ira.c:5561)
==13612== by 0xA22127: execute_one_pass(opt_pass*) (passes.c:2311)
==13612== by 0xA225F5: execute_pass_list_1(opt_pass*) (passes.c:2363)
==13612== by 0xA22607: execute_pass_list_1(opt_pass*) (passes.c:2364)
==13612== by 0xA22648: execute_pass_list(function*, opt_pass*) (passes.c:2374)
==13612== by 0x726F04: cgraph_node::expand() (cgraphunit.c:1773)
==13612== by 0x727BCF: output_in_order(bool) (cgraphunit.c:2011)
Following patch just replaces XNEWVAR with XCNEWVAR and it solves all these errors.
Ready for trunk?
Thanks,
Martin
>From ba3abc54772141011b1f8737201a3046031c0e42 Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Fri, 5 Dec 2014 13:23:30 +0100
Subject: [PATCH] sparseset: condition decision based on uninitialized memory.
gcc/ChangeLog:
2014-12-05 Martin Liska <mliska@suse.cz>
* sparseset.c (sparseset_alloc): XNEWVAR is replaced with XCNEWVAR.
---
gcc/sparseset.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/sparseset.c b/gcc/sparseset.c
index 628a6e2..f5e5e38b 100644
--- a/gcc/sparseset.c
+++ b/gcc/sparseset.c
@@ -30,7 +30,7 @@ sparseset_alloc (SPARSESET_ELT_TYPE n_elms)
unsigned int n_bytes = sizeof (struct sparseset_def)
+ ((n_elms - 1) * 2 * sizeof (SPARSESET_ELT_TYPE));
- sparseset set = XNEWVAR (struct sparseset_def, n_bytes);
+ sparseset set = XCNEWVAR (struct sparseset_def, n_bytes);
/* Mark the sparseset as defined to silence some valgrind uninitialized
read errors when accessing set->sparse[n] when "n" is not, and never has
--
2.1.2