Patchwork [asan] Patch - fix an ICE in asan.c

login
register
mail settings
Submitter Jakub Jelinek
Date Nov. 12, 2012, 4:44 p.m.
Message ID <20121112164404.GP1886@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/198417/
State New
Headers show

Comments

Jakub Jelinek - Nov. 12, 2012, 4:44 p.m.
On Mon, Nov 12, 2012 at 04:45:55PM +0100, Tobias Burnus wrote:
> First, I have a small hyphen fix patch, which is on top of your
> merge branch. (The "asan" branch itself is okay.)

This patch is preapproved with appropriate ChangeLog entry.
Thanks.

> --- invoke.texi.orig    2012-11-12 15:41:31.000000000 +0100
> +++ invoke.texi 2012-11-12 15:16:33.856424039 +0100
> @@ -356,5 +356,5 @@ Objective-C and Objective-C++ Dialects}.
>  -falign-labels[=@var{n}] -falign-loops[=@var{n}] -faddress-sanitizer @gol
> ---fassociative-math fauto-inc-dec -fbranch-probabilities @gol
> ---fbranch-target-load-optimize fbranch-target-load-optimize2 @gol
> ---fbtr-bb-exclusive -fcaller-saves @gol
> +-fassociative-math -fauto-inc-dec -fbranch-probabilities @gol
> +-fbranch-target-load-optimize -fbranch-target-load-optimize2 @gol
> +-fbtr-bb-exclusive -fcaller-saves @gol
>  -fcheck-data-deps -fcombine-stack-adjustments -fconserve-stack @gol

> Secondly, the following code fails on both the asan branch and on
> the merge branch with an ICE:
> 
> void TI_ASM_Pack_Inst (const int *opnd)
> {
>   int bopnd[5];
>   __builtin_bcopy(opnd, bopnd, sizeof (bopnd));
> }

The bug is elsewhere, the following patch should fix this
(and I've reordered the assignments according to the call arg
number, so that it is more readable at the same time).
Ok for trunk?

2012-11-12  Jakub Jelinek  <jakub@redhat.com>

	* asan.c (instrument_builtin_call) <case BUILT_IN_BCOPY>: Fix up
	dest assignment.



	Jakub
Dodji Seketeli - Nov. 12, 2012, 4:51 p.m.
Jakub Jelinek <jakub@redhat.com> writes:

> The bug is elsewhere, the following patch should fix this
> (and I've reordered the assignments according to the call arg
> number, so that it is more readable at the same time).
> Ok for trunk?
>
> 2012-11-12  Jakub Jelinek  <jakub@redhat.com>
>
> 	* asan.c (instrument_builtin_call) <case BUILT_IN_BCOPY>: Fix up
> 	dest assignment.
>
> --- gcc/asan.c.jj	2012-11-12 17:16:16.000000000 +0100
> +++ gcc/asan.c	2012-11-12 17:39:19.673022734 +0100
> @@ -1044,16 +1044,16 @@ instrument_builtin_call (gimple_stmt_ite
>        /* (s, s, n) style memops.  */
>      case BUILT_IN_BCMP:
>      case BUILT_IN_MEMCMP:
> -      len = gimple_call_arg (call, 2);
>        source0 = gimple_call_arg (call, 0);
>        source1 = gimple_call_arg (call, 1);
> +      len = gimple_call_arg (call, 2);
>        break;
>  
>        /* (src, dest, n) style memops.  */
>      case BUILT_IN_BCOPY:
> -      len = gimple_call_arg (call, 2);
>        source0 = gimple_call_arg (call, 0);
> -      dest = gimple_call_arg (call, 2);
> +      dest = gimple_call_arg (call, 1);
> +      len = gimple_call_arg (call, 2);
>        break;
>  
>        /* (dest, src, n) style memops.  */

Indeed.  I was about to send a similar patch after Tobias' report.

Thanks.
Markus Trippelsdorf - Nov. 12, 2012, 5:13 p.m.
Another ICE:

 % cat test.ii
 int i;

 % g++ -faddress-sanitizer -c -g -O1 test.ii
test.ii:1:7: internal compiler error: Segmentation fault
  int i;
       ^
0xa5cb5f crash_signal
        /home/markus/gcc/gcc/toplev.c:334
inconsistent DWARF line number info
0x4cf588 cp_classify_record
        /home/markus/gcc/gcc/cp/cp-lang.c:131
0x7ee7e3 record_type_tag
        /home/markus/gcc/gcc/dwarf2out.c:16914
0x7ee7e3 gen_struct_or_union_type_die
        /home/markus/gcc/gcc/dwarf2out.c:19078
0x7ee7e3 gen_tagged_type_die
        /home/markus/gcc/gcc/dwarf2out.c:19303
0x7ee7e3 gen_tagged_type_die
        /home/markus/gcc/gcc/dwarf2out.c:19246
0x7f5dce gen_type_die_with_usage
        /home/markus/gcc/gcc/dwarf2out.c:19450
0x7f6b9c modified_type_die
        /home/markus/gcc/gcc/dwarf2out.c:10180
0x7f68c5 modified_type_die
        /home/markus/gcc/gcc/dwarf2out.c:10238
0x7f8cd0 add_type_attribute
        /home/markus/gcc/gcc/dwarf2out.c:16486
0x7f4bf1 gen_formal_parameter_die
        /home/markus/gcc/gcc/dwarf2out.c:17079
0x7f520b gen_formal_types_die
        /home/markus/gcc/gcc/dwarf2out.c:17175
0x7f181c gen_subprogram_die
        /home/markus/gcc/gcc/dwarf2out.c:17909
0x7f8075 force_decl_die
        /home/markus/gcc/gcc/dwarf2out.c:19733
0x7f8721 resolve_addr
        /home/markus/gcc/gcc/dwarf2out.c:22661
0x7f83f9 resolve_addr
        /home/markus/gcc/gcc/dwarf2out.c:22683
0x7f83f9 resolve_addr
        /home/markus/gcc/gcc/dwarf2out.c:22683
0x807392 dwarf2out_finish
        /home/markus/gcc/gcc/dwarf2out.c:23305
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

Patch

--- gcc/asan.c.jj	2012-11-12 17:16:16.000000000 +0100
+++ gcc/asan.c	2012-11-12 17:39:19.673022734 +0100
@@ -1044,16 +1044,16 @@  instrument_builtin_call (gimple_stmt_ite
       /* (s, s, n) style memops.  */
     case BUILT_IN_BCMP:
     case BUILT_IN_MEMCMP:
-      len = gimple_call_arg (call, 2);
       source0 = gimple_call_arg (call, 0);
       source1 = gimple_call_arg (call, 1);
+      len = gimple_call_arg (call, 2);
       break;
 
       /* (src, dest, n) style memops.  */
     case BUILT_IN_BCOPY:
-      len = gimple_call_arg (call, 2);
       source0 = gimple_call_arg (call, 0);
-      dest = gimple_call_arg (call, 2);
+      dest = gimple_call_arg (call, 1);
+      len = gimple_call_arg (call, 2);
       break;
 
       /* (dest, src, n) style memops.  */