This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: combine.c accesses uninitialized variable :-(
- To: gcc-patches at gcc dot gnu dot org
- Subject: Re: combine.c accesses uninitialized variable :-(
- From: Andreas Jaeger <aj at suse dot de>
- Date: 12 Jan 2001 10:57:17 +0100
- Cc: Jan Hubicka <jh at suse dot cz>
- References: <u8itnlupnk.fsf@gromit.rhein-neckar.de>
>>>>> Andreas Jaeger writes:
> The last patch to combine accesses uninitialized memory. I noticed
> this since compilation of glibc produced an ICE.
> Here's a patch that also fixes another problem (a prototype declared
> with static but the function doesn't have static).
> Ok to install if it passes bootstrap and checking?
> Andreas
> 2001-01-12 Andreas Jaeger <aj@suse.de>
> * combine.c (reversed_comparison): Fix typo in last patch.
> (combine_reversed_comparison_code): Make static to follow
> prototype declaration.
> Index: combine.c
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/combine.c,v
> retrieving revision 1.174
> diff -u -r1.174 combine.c
> --- combine.c 2001/01/11 23:10:30 1.174
> +++ combine.c 2001/01/12 08:42:28
> @@ -11123,7 +11123,7 @@
>
> /* Like jump.c' reversed_comparison_code, but use combine infrastructure for
> searching backward. */
> -enum rtx_code
> +static enum rtx_code
> combine_reversed_comparison_code (exp)
> rtx exp;
> {
> @@ -11135,7 +11135,7 @@
> return code1;
> /* Otherwise try and find where the condition codes were last set and
> use that. */
> - x = get_last_value (XEXP (x, 0));
> + x = get_last_value (XEXP (exp, 0));
> if (GET_CODE (x) != COMPARE)
> return UNKNOWN;
> return reversed_comparison_code_parts (GET_CODE (exp),
This patch doesn't fix the problem :-(
(gdb) r -fpreprocessed init-first.i -quiet -dumpbase init-first.c -march=pentiumpro -mcpu=i686 -g -O3 -Wall -Wbad-function-cast -Wcomment -Wcomments -Winline -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wmultichar -Wsign-compare -Wstrict-prototypes -Wtrigraphs -Wwrite-strings -version -freorder-blocks -fssa -fkeep-inline-functions -o init-first.s
GNU CPP version 2.97 20010111 (experimental) (cpplib) (i386 Linux/ELF)
GNU C version 2.97 20010111 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 2.97 20010111 (experimental).
Breakpoint 1, combine_reversed_comparison_code (exp=0x40325130)
at /cvs/gcc/gcc/combine.c:11138
11138 x = get_last_value (XEXP (exp, 0));
(gdb) p exp
$3 = 0x40325130
(gdb) p *exp
$4 = {code = LT, mode = VOIDmode, jump = 0, call = 0, unchanging = 0, volatil = 0,
in_struct = 0, used = 1, integrated = 0, frame_related = 0, fld = {{rtwint = 1077039360,
rtint = 1077039360, rtuint = 1077039360, rtstr = 0x40325100 "9", rtx = 0x40325100,
rtvec = 0x40325100, rttype = 1077039360, rt_addr_diff_vec_flags = {min_align = 0,
base_after_vec = 1, min_after_vec = 0, max_after_vec = 0, min_after_base = 0,
max_after_base = 1, offset_unsigned = 0, 1, scale = 50}, rt_cselib = 0x40325100,
rtbit = 0x40325100, rttree = 0x40325100, bb = 0x40325100}}}
(gdb) p x
$5 = 0x34
(gdb) n
11139 if (GET_CODE (x) != COMPARE)
(gdb) p x
$6 = 0x0
(gdb) bt
#0 combine_reversed_comparison_code (exp=0x40325130) at /cvs/gcc/gcc/combine.c:11139
#1 0x81aee3e in simplify_if_then_else (x=0x40325170) at /cvs/gcc/gcc/combine.c:4644
#2 0x81ad689 in combine_simplify_rtx (x=0x40325170, op0_mode=VOIDmode, last=0, in_dest=0)
at /cvs/gcc/gcc/combine.c:4482
#3 0x81acba0 in subst (x=0x40325170, from=0x40325140, to=0x4018e3f8, in_dest=0,
unique_copy=0) at /cvs/gcc/gcc/combine.c:3466
#4 0x81acc2a in subst (x=0x40325180, from=0x40325140, to=0x4018e3f8, in_dest=0,
unique_copy=0) at /cvs/gcc/gcc/combine.c:3436
#5 0x81a9b8f in try_combine (i3=0x40323f40, i2=0x40323f00, i1=0x0,
new_direct_jump_p=0xbfffeea4) at /cvs/gcc/gcc/combine.c:1935
#6 0x81a86a0 in combine_instructions (f=0x4030d4a0, nregs=131) at /cvs/gcc/gcc/combine.c:635
#7 0x8097481 in rest_of_compilation (decl=0x4031c3a8) at /cvs/gcc/gcc/toplev.c:3290
#8 0x8062a35 in c_expand_body (fndecl=0x4031c3a8, nested_p=0) at /cvs/gcc/gcc/c-decl.c:6699
#9 0x8062721 in finish_function (nested=0) at /cvs/gcc/gcc/c-decl.c:6620
#10 0x804a126 in yyparse_1 () at /usr/share/bison.simple:323
#11 0x8095f3d in compile_file (name=0x8383d51 "init-first.i") at /cvs/gcc/gcc/toplev.c:2374
#12 0x8099b2c in main (argc=30, argv=0xbffff55c) at /cvs/gcc/gcc/toplev.c:4872
#13 0x40042baf in __libc_start_main () from /lib/libc.so.6
The file init-first.i is available at
ftp.suse.com/pub/people/aj/init-first.i.
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj