diff mbox

libsanitizer merge from upstream r191666

Message ID 20131029121355.GY30970@tucnak.zalov.cz
State New
Headers show

Commit Message

Jakub Jelinek Oct. 29, 2013, 12:13 p.m. UTC
> On Wed, Oct 2, 2013 at 12:51 PM, Konstantin Serebryany
> > 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> >
> >         * g++.dg/asan/asan_test.cc: Update the test
> >         to match the fresh asan run-time.
> >         * c-c++-common/asan/stack-overflow-1.c: Ditto.
> >
> > =========== gcc/ChangeLog
> >
> > 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> >
> >         * asan.c: Update to match the changed asan API.
> >         (asan_emit_stack_protection): update the string stored in the
> >         stack red zone to match new API. Store the PC of the current
> >         function in the red zone.
> >         (asan_global_struct): update the __asan_global definition to match
> >         the new API.
> >         (asan_add_global): Ditto.
> >         * sanitizer.def: rename __asan_init_v1 to __asan_init_v3

The "Update to match the changed asan API." should either be
dropped, or come on a line before the * asan.c (asan_emit_stack_protection):
line.  All descriptions should start with capital letters, end with ., two
spaces after . if followed by another sentence.

Besides that, here is (completely untested) attempt to give you
the pc of the first instruction of the function and two minor changes
(pp_string (something, "") is useless and in two spots I've noticed
you didn't add space before ( in function call).

Finally, if the new libasan is ABI incompatible with the old one, which
seems it is, then libsanitizer/asan/libtool-version (and perhaps also
libsanitizer/tsan/libtool-version, haven't looked if that one is ABI
compatible or not) needs to be bumped (to 1:0:0 ?).



	Jakub

Comments

Jakub Jelinek Oct. 29, 2013, 1:52 p.m. UTC | #1
On Tue, Oct 29, 2013 at 06:49:30AM -0700, Konstantin Serebryany wrote:
> Thanks!
> (At this time I will be slow with response due to travel)

BTW, don't have compiled clang/llvm pre-3.4 around to look at, for the use
after return, do you emit always the the __asan_*malloc/free calls for the
stack vars, or only conditionally based on some compiler flag (and in the
latter case, is that flag on by default or not)?

	Jakub
Konstantin Serebryany Oct. 29, 2013, 2:05 p.m. UTC | #2
On Tue, Oct 29, 2013 at 6:52 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Oct 29, 2013 at 06:49:30AM -0700, Konstantin Serebryany wrote:
>> Thanks!
>> (At this time I will be slow with response due to travel)
>
> BTW, don't have compiled clang/llvm pre-3.4 around to look at, for the use
> after return, do you emit always the the __asan_*malloc/free calls for the
> stack vars, or only conditionally based on some compiler flag (and in the
> latter case, is that flag on by default or not)?

The calls are emitted by default, but the __asan_stack_malloc call is
done under a run-time flag
__asan_option_detect_stack_use_after_return.
So, to use the stack-use-after-return feature you should simply
compile with -fsanitize=address and then at run-time
pass ASAN_OPTIONS=detect_stack_use_after_return=1
For small stack frame sizes the call to __asan_stack_free is inlined
(as a performance optimization, not mandatory).

Here is how the IR looks like:

void bar(void*);
void foo() {
  char x[10000];
  bar(&x);
}


define void @foo() #0 {
entry:
  %MyAlloca = alloca [10080 x i8], align 32
  %0 = ptrtoint [10080 x i8]* %MyAlloca to i64
  %1 = load i32* @__asan_option_detect_stack_use_after_return
  %2 = icmp ne i32 %1, 0
  br i1 %2, label %3, label %5

; <label>:3                                       ; preds = %entry
  %4 = call i64 @__asan_stack_malloc_8(i64 10080, i64 %0)
  br label %5

; <label>:5                                       ; preds = %entry, %3
  %6 = phi i64 [ %0, %entry ], [ %4, %3 ]
...
  call void @__asan_stack_free_8(i64 %6, i64 10080, i64 %0)
  ret void
}


So, when the UAR is disabled at run-time we pay a very small
additional price for this code
(less than 1% on avg on SPEC).
When it is enabled, we pay more:
https://code.google.com/p/address-sanitizer/wiki/UseAfterReturn#Performance

--kcc

>
>         Jakub
Konstantin Serebryany Oct. 29, 2013, 11:54 p.m. UTC | #3
Jakub,

Your patch seems to do what it should:

% ../gcc-inst/bin/g++ -gdwarf-2 -fsanitize=address -static-libasan
../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c && ./a.out
...
Address 0x7fffb8ec95ca is located in stack of thread T0 at offset 42 in frame
    #0 0x44bd73 in main
../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13

But now when I run the tests I get this:

FAIL: c-c++-common/asan/clone-test-1.c  -O2 -flto
-fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: c-c++-common/asan/clone-test-1.c  -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  (test for excess errors)
FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -fno-use-linker-plugin
-flto-partition=none  (test for excess errors)
FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  (test for excess errors)
FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto
-fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
FAIL: c-c++-common/asan/swapcontext-test-1.c  -O2 -flto
-fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: c-c++-common/asan/swapcontext-test-1.c  -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto
-fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  (test for excess errors)

W/o your change they pass.
Could you please remind me how to debug this (i.e. how to run the
exact test commands manually)?

Thanks!
--kcc

On Tue, Oct 29, 2013 at 6:49 AM, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> Thanks!
> (At this time I will be slow with response due to travel)
>
> --kcc
>
>
> On Tue, Oct 29, 2013 at 5:13 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>>
>> > On Wed, Oct 2, 2013 at 12:51 PM, Konstantin Serebryany
>> > > 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>> > >
>> > >         * g++.dg/asan/asan_test.cc: Update the test
>> > >         to match the fresh asan run-time.
>> > >         * c-c++-common/asan/stack-overflow-1.c: Ditto.
>> > >
>> > > =========== gcc/ChangeLog
>> > >
>> > > 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>> > >
>> > >         * asan.c: Update to match the changed asan API.
>> > >         (asan_emit_stack_protection): update the string stored in the
>> > >         stack red zone to match new API. Store the PC of the current
>> > >         function in the red zone.
>> > >         (asan_global_struct): update the __asan_global definition to
>> > > match
>> > >         the new API.
>> > >         (asan_add_global): Ditto.
>> > >         * sanitizer.def: rename __asan_init_v1 to __asan_init_v3
>>
>> The "Update to match the changed asan API." should either be
>> dropped, or come on a line before the * asan.c
>> (asan_emit_stack_protection):
>> line.  All descriptions should start with capital letters, end with ., two
>> spaces after . if followed by another sentence.
>>
>> Besides that, here is (completely untested) attempt to give you
>> the pc of the first instruction of the function and two minor changes
>> (pp_string (something, "") is useless and in two spots I've noticed
>> you didn't add space before ( in function call).
>>
>> Finally, if the new libasan is ABI incompatible with the old one, which
>> seems it is, then libsanitizer/asan/libtool-version (and perhaps also
>> libsanitizer/tsan/libtool-version, haven't looked if that one is ABI
>> compatible or not) needs to be bumped (to 1:0:0 ?).
>>
>> --- gcc/asan.c.jj       2013-10-29 11:58:30.000000000 +0100
>> +++ gcc/asan.c  2013-10-29 13:04:07.709667677 +0100
>> @@ -921,6 +921,15 @@ asan_clear_shadow (rtx shadow_mem, HOST_
>>    add_int_reg_note (jump, REG_BR_PROB, REG_BR_PROB_BASE * 80 / 100);
>>  }
>>
>> +void
>> +asan_function_start (void)
>> +{
>> +  section *fnsec = function_section (current_function_decl);
>> +  switch_to_section (fnsec);
>> +  ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LASANPC",
>> +                         current_function_funcdef_no);
>> +}
>> +
>>  /* Insert code to protect stack vars.  The prologue sequence should be
>> emitted
>>     directly, epilogue sequence returned.  BASE is the register holding
>> the
>>     stack base, against which OFFSETS array offsets are relative to,
>> OFFSETS
>> @@ -936,12 +945,13 @@ asan_emit_stack_protection (rtx base, HO
>>                             int length)
>>  {
>>    rtx shadow_base, shadow_mem, ret, mem;
>> +  char buf[30];
>>    unsigned char shadow_bytes[4];
>>    HOST_WIDE_INT base_offset = offsets[length - 1], offset, prev_offset;
>>    HOST_WIDE_INT last_offset, last_size;
>>    int l;
>>    unsigned char cur_shadow_byte = ASAN_STACK_MAGIC_LEFT;
>> -  tree str_cst;
>> +  tree str_cst, decl;
>>
>>    if (shadow_ptr_types[0] == NULL_TREE)
>>      asan_init_shadow_ptr_types ();
>> @@ -949,7 +959,6 @@ asan_emit_stack_protection (rtx base, HO
>>    /* First of all, prepare the description string.  */
>>    pretty_printer asan_pp;
>>
>> -  pp_string (&asan_pp, "");
>>    pp_decimal_int (&asan_pp, length / 2 - 1);
>>    pp_space (&asan_pp);
>>    for (l = length - 2; l; l -= 2)
>> @@ -980,7 +989,17 @@ asan_emit_stack_protection (rtx base, HO
>>    mem = adjust_address (mem, VOIDmode, GET_MODE_SIZE (ptr_mode));
>>    emit_move_insn (mem, expand_normal (str_cst));
>>    mem = adjust_address (mem, VOIDmode, GET_MODE_SIZE (ptr_mode));
>> -  emit_move_insn (mem, expand_normal (str_cst));  // FIXME: should be
>> cur_pc.
>> +  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC",
>> current_function_funcdef_no);
>> +  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
>> +                    VAR_DECL, get_identifier (buf), char_type_node);
>> +  TREE_ADDRESSABLE (decl) = 1;
>> +  TREE_READONLY (decl) = 1;
>> +  DECL_ARTIFICIAL (decl) = 1;
>> +  DECL_IGNORED_P (decl) = 1;
>> +  TREE_STATIC (decl) = 1;
>> +  TREE_PUBLIC (decl) = 0;
>> +  TREE_USED (decl) = 1;
>> +  emit_move_insn (mem, expand_normal (build_fold_addr_expr (decl)));
>>    shadow_base = expand_binop (Pmode, lshr_optab, base,
>>                               GEN_INT (ASAN_SHADOW_SHIFT),
>>                               NULL_RTX, 1, OPTAB_DIRECT);
>> @@ -1979,8 +1998,8 @@ asan_add_global (tree decl, tree type, v
>>      pp_string (&asan_pp, "<unknown>");
>>    str_cst = asan_pp_string (&asan_pp);
>>
>> -  pp_string(&module_name_pp, main_input_filename);
>> -  module_name_cst = asan_pp_string(&module_name_pp);
>> +  pp_string (&module_name_pp, main_input_filename);
>> +  module_name_cst = asan_pp_string (&module_name_pp);
>>
>>    if (asan_needs_local_alias (decl))
>>      {
>> --- gcc/asan.h.jj       2013-01-11 09:02:50.000000000 +0100
>> +++ gcc/asan.h  2013-10-29 12:37:54.190798947 +0100
>> @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.
>>  #ifndef TREE_ASAN
>>  #define TREE_ASAN
>>
>> +extern void asan_function_start (void);
>>  extern void asan_finish_file (void);
>>  extern rtx asan_emit_stack_protection (rtx, HOST_WIDE_INT *, tree *,
>> int);
>>  extern bool asan_protect_global (tree);
>> --- gcc/final.c.jj      2013-10-23 14:43:12.000000000 +0200
>> +++ gcc/final.c 2013-10-29 12:49:33.609176613 +0100
>> @@ -78,6 +78,7 @@ along with GCC; see the file COPYING3.
>>  #include "cfgloop.h"
>>  #include "params.h"
>>  #include "tree-pretty-print.h" /* for dump_function_header */
>> +#include "asan.h"
>>
>>  #ifdef XCOFF_DEBUGGING_INFO
>>  #include "xcoffout.h"          /* Needed for external data
>> @@ -1738,6 +1739,9 @@ final_start_function (rtx first, FILE *f
>>
>>    high_block_linenum = high_function_linenum = last_linenum;
>>
>> +  if (flag_sanitize & SANITIZE_ADDRESS)
>> +    asan_function_start ();
>> +
>>    if (!DECL_IGNORED_P (current_function_decl))
>>      debug_hooks->begin_prologue (last_linenum, last_filename);
>>
>>
>>
>>         Jakub
>
>
Konstantin Serebryany Oct. 30, 2013, 12:15 a.m. UTC | #4
Actually, I guessed the flags:

 % ../gcc-inst/bin/g++ -g -fsanitize=address -static-libasan -O2 -flto
-fno-use-linker-plugin -flto-partition=none
../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c; ./a.out
2>&1

/tmp/ccgSw6NI.lto.o: In function `main':
../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13:
undefined reference to `.LASANPC0.2585'
collect2: error: ld returned 1 exit status

Looks like this patch is not friendly to -flto

--kcc

On Tue, Oct 29, 2013 at 4:54 PM, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> Jakub,
>
> Your patch seems to do what it should:
>
> % ../gcc-inst/bin/g++ -gdwarf-2 -fsanitize=address -static-libasan
> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c && ./a.out
> ...
> Address 0x7fffb8ec95ca is located in stack of thread T0 at offset 42 in frame
>     #0 0x44bd73 in main
> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13
>
> But now when I run the tests I get this:
>
> FAIL: c-c++-common/asan/clone-test-1.c  -O2 -flto
> -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
> FAIL: c-c++-common/asan/clone-test-1.c  -O2 -flto -fuse-linker-plugin
> -fno-fat-lto-objects  (test for excess errors)
> FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -fno-use-linker-plugin
> -flto-partition=none  (test for excess errors)
> FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -fuse-linker-plugin
> -fno-fat-lto-objects  (test for excess errors)
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto
> -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto
> -fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
> FAIL: c-c++-common/asan/swapcontext-test-1.c  -O2 -flto
> -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
> FAIL: c-c++-common/asan/swapcontext-test-1.c  -O2 -flto
> -fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto
> -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto -fuse-linker-plugin
> -fno-fat-lto-objects  (test for excess errors)
>
> W/o your change they pass.
> Could you please remind me how to debug this (i.e. how to run the
> exact test commands manually)?
>
> Thanks!
> --kcc
>
> On Tue, Oct 29, 2013 at 6:49 AM, Konstantin Serebryany
> <konstantin.s.serebryany@gmail.com> wrote:
>> Thanks!
>> (At this time I will be slow with response due to travel)
>>
>> --kcc
>>
>>
>> On Tue, Oct 29, 2013 at 5:13 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>>>
>>> > On Wed, Oct 2, 2013 at 12:51 PM, Konstantin Serebryany
>>> > > 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>>> > >
>>> > >         * g++.dg/asan/asan_test.cc: Update the test
>>> > >         to match the fresh asan run-time.
>>> > >         * c-c++-common/asan/stack-overflow-1.c: Ditto.
>>> > >
>>> > > =========== gcc/ChangeLog
>>> > >
>>> > > 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>>> > >
>>> > >         * asan.c: Update to match the changed asan API.
>>> > >         (asan_emit_stack_protection): update the string stored in the
>>> > >         stack red zone to match new API. Store the PC of the current
>>> > >         function in the red zone.
>>> > >         (asan_global_struct): update the __asan_global definition to
>>> > > match
>>> > >         the new API.
>>> > >         (asan_add_global): Ditto.
>>> > >         * sanitizer.def: rename __asan_init_v1 to __asan_init_v3
>>>
>>> The "Update to match the changed asan API." should either be
>>> dropped, or come on a line before the * asan.c
>>> (asan_emit_stack_protection):
>>> line.  All descriptions should start with capital letters, end with ., two
>>> spaces after . if followed by another sentence.
>>>
>>> Besides that, here is (completely untested) attempt to give you
>>> the pc of the first instruction of the function and two minor changes
>>> (pp_string (something, "") is useless and in two spots I've noticed
>>> you didn't add space before ( in function call).
>>>
>>> Finally, if the new libasan is ABI incompatible with the old one, which
>>> seems it is, then libsanitizer/asan/libtool-version (and perhaps also
>>> libsanitizer/tsan/libtool-version, haven't looked if that one is ABI
>>> compatible or not) needs to be bumped (to 1:0:0 ?).
>>>
>>> --- gcc/asan.c.jj       2013-10-29 11:58:30.000000000 +0100
>>> +++ gcc/asan.c  2013-10-29 13:04:07.709667677 +0100
>>> @@ -921,6 +921,15 @@ asan_clear_shadow (rtx shadow_mem, HOST_
>>>    add_int_reg_note (jump, REG_BR_PROB, REG_BR_PROB_BASE * 80 / 100);
>>>  }
>>>
>>> +void
>>> +asan_function_start (void)
>>> +{
>>> +  section *fnsec = function_section (current_function_decl);
>>> +  switch_to_section (fnsec);
>>> +  ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LASANPC",
>>> +                         current_function_funcdef_no);
>>> +}
>>> +
>>>  /* Insert code to protect stack vars.  The prologue sequence should be
>>> emitted
>>>     directly, epilogue sequence returned.  BASE is the register holding
>>> the
>>>     stack base, against which OFFSETS array offsets are relative to,
>>> OFFSETS
>>> @@ -936,12 +945,13 @@ asan_emit_stack_protection (rtx base, HO
>>>                             int length)
>>>  {
>>>    rtx shadow_base, shadow_mem, ret, mem;
>>> +  char buf[30];
>>>    unsigned char shadow_bytes[4];
>>>    HOST_WIDE_INT base_offset = offsets[length - 1], offset, prev_offset;
>>>    HOST_WIDE_INT last_offset, last_size;
>>>    int l;
>>>    unsigned char cur_shadow_byte = ASAN_STACK_MAGIC_LEFT;
>>> -  tree str_cst;
>>> +  tree str_cst, decl;
>>>
>>>    if (shadow_ptr_types[0] == NULL_TREE)
>>>      asan_init_shadow_ptr_types ();
>>> @@ -949,7 +959,6 @@ asan_emit_stack_protection (rtx base, HO
>>>    /* First of all, prepare the description string.  */
>>>    pretty_printer asan_pp;
>>>
>>> -  pp_string (&asan_pp, "");
>>>    pp_decimal_int (&asan_pp, length / 2 - 1);
>>>    pp_space (&asan_pp);
>>>    for (l = length - 2; l; l -= 2)
>>> @@ -980,7 +989,17 @@ asan_emit_stack_protection (rtx base, HO
>>>    mem = adjust_address (mem, VOIDmode, GET_MODE_SIZE (ptr_mode));
>>>    emit_move_insn (mem, expand_normal (str_cst));
>>>    mem = adjust_address (mem, VOIDmode, GET_MODE_SIZE (ptr_mode));
>>> -  emit_move_insn (mem, expand_normal (str_cst));  // FIXME: should be
>>> cur_pc.
>>> +  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC",
>>> current_function_funcdef_no);
>>> +  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
>>> +                    VAR_DECL, get_identifier (buf), char_type_node);
>>> +  TREE_ADDRESSABLE (decl) = 1;
>>> +  TREE_READONLY (decl) = 1;
>>> +  DECL_ARTIFICIAL (decl) = 1;
>>> +  DECL_IGNORED_P (decl) = 1;
>>> +  TREE_STATIC (decl) = 1;
>>> +  TREE_PUBLIC (decl) = 0;
>>> +  TREE_USED (decl) = 1;
>>> +  emit_move_insn (mem, expand_normal (build_fold_addr_expr (decl)));
>>>    shadow_base = expand_binop (Pmode, lshr_optab, base,
>>>                               GEN_INT (ASAN_SHADOW_SHIFT),
>>>                               NULL_RTX, 1, OPTAB_DIRECT);
>>> @@ -1979,8 +1998,8 @@ asan_add_global (tree decl, tree type, v
>>>      pp_string (&asan_pp, "<unknown>");
>>>    str_cst = asan_pp_string (&asan_pp);
>>>
>>> -  pp_string(&module_name_pp, main_input_filename);
>>> -  module_name_cst = asan_pp_string(&module_name_pp);
>>> +  pp_string (&module_name_pp, main_input_filename);
>>> +  module_name_cst = asan_pp_string (&module_name_pp);
>>>
>>>    if (asan_needs_local_alias (decl))
>>>      {
>>> --- gcc/asan.h.jj       2013-01-11 09:02:50.000000000 +0100
>>> +++ gcc/asan.h  2013-10-29 12:37:54.190798947 +0100
>>> @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.
>>>  #ifndef TREE_ASAN
>>>  #define TREE_ASAN
>>>
>>> +extern void asan_function_start (void);
>>>  extern void asan_finish_file (void);
>>>  extern rtx asan_emit_stack_protection (rtx, HOST_WIDE_INT *, tree *,
>>> int);
>>>  extern bool asan_protect_global (tree);
>>> --- gcc/final.c.jj      2013-10-23 14:43:12.000000000 +0200
>>> +++ gcc/final.c 2013-10-29 12:49:33.609176613 +0100
>>> @@ -78,6 +78,7 @@ along with GCC; see the file COPYING3.
>>>  #include "cfgloop.h"
>>>  #include "params.h"
>>>  #include "tree-pretty-print.h" /* for dump_function_header */
>>> +#include "asan.h"
>>>
>>>  #ifdef XCOFF_DEBUGGING_INFO
>>>  #include "xcoffout.h"          /* Needed for external data
>>> @@ -1738,6 +1739,9 @@ final_start_function (rtx first, FILE *f
>>>
>>>    high_block_linenum = high_function_linenum = last_linenum;
>>>
>>> +  if (flag_sanitize & SANITIZE_ADDRESS)
>>> +    asan_function_start ();
>>> +
>>>    if (!DECL_IGNORED_P (current_function_decl))
>>>      debug_hooks->begin_prologue (last_linenum, last_filename);
>>>
>>>
>>>
>>>         Jakub
>>
>>
Jakub Jelinek Oct. 30, 2013, 7:03 a.m. UTC | #5
On Tue, Oct 29, 2013 at 05:15:24PM -0700, Konstantin Serebryany wrote:
> Actually, I guessed the flags:

You don't have to guess them, if you look into
testsuite/g++/g++.log (or testsuite/gcc/gcc.log etc.), you can find them
there.

>  % ../gcc-inst/bin/g++ -g -fsanitize=address -static-libasan -O2 -flto
> -fno-use-linker-plugin -flto-partition=none
> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c; ./a.out
> 2>&1
> 
> /tmp/ccgSw6NI.lto.o: In function `main':
> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13:
> undefined reference to `.LASANPC0.2585'
> collect2: error: ld returned 1 exit status
> 
> Looks like this patch is not friendly to -flto

I guess if you do:
...
-  tree str_cst;
+  tree str_cst, decl, id;
...
+  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC", current_function_funcdef_no);
+  id = get_identifier (buf);
+  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+                    VAR_DECL, id, char_type_node);
+  SET_DECL_ASSEMBLER_NAME (decl, id);
+  TREE_ADDRESSABLE (decl) = 1;
...

it might work even for -flto.  The problem with -flto is that the default
set_decl_assembler_name langhook for -flto appends dot and some number to
the non-exported names, which is undesirable here, because we already make
sure those first numbers are unique for the whole compilation unit.

	Jakub
Konstantin Serebryany Nov. 1, 2013, 11:13 p.m. UTC | #6
Jukub,

This works!
New patch attached.

Tested:
make  -C gcc check-g{cc,++}
RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp'
make check -C gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp'

=========== gcc/testsuite/ChangeLog

2013-10-XX  Kostya Serebryany  <kcc@google.com>

        * g++.dg/asan/asan_test.cc: Update the test
        to match the fresh asan run-time.
        * c-c++-common/asan/stack-overflow-1.c: Ditto.

=========== gcc/ChangeLog

2013-10-XX  Kostya Serebryany  <kcc@google.com>

        Update to match the changed asan API.
        * asan.c:
        (asan_function_start): New function.
        (asan_emit_stack_protection): Update the string stored in the
        stack red zone to match new API.  Store the PC of the current
        function in the red zone.
        (asan_global_struct): Update the __asan_global definition to match
        the new API.
        (asan_add_global): Ditto.
        * asan.h: Declare asan_function_start.
        * final.c:
        (final_start_function): Call asan_function_start.
        * sanitizer.def: Rename __asan_init_v1 to __asan_init_v3.

=========== libsanitizer/ChangeLog

2013-10-XX  Kostya Serebryany  <kcc@google.com>

        * All source files: Merge from upstream r191666.
        * merge.sh: Added lsan.
        * configure.ac: Added lsan.
        * Makefile.am: Added lsan.
        * sanitizer_common/Makefile.am: Added lsan.
        * asan/Makefile.am: Added dependency on lsan.
        * lsan/Makefile.am: New file.
        * asan/Makefile.in: Regenerate.
        * lsan/Makefile.in: Regenerate.
        * Makefile.in: Regenerate.
        * configure: Regenerate.
        * sanitizer_common/Makefile.in: Regenerate.

On Wed, Oct 30, 2013 at 12:03 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Oct 29, 2013 at 05:15:24PM -0700, Konstantin Serebryany wrote:
>> Actually, I guessed the flags:
>
> You don't have to guess them, if you look into
> testsuite/g++/g++.log (or testsuite/gcc/gcc.log etc.), you can find them
> there.
>
>>  % ../gcc-inst/bin/g++ -g -fsanitize=address -static-libasan -O2 -flto
>> -fno-use-linker-plugin -flto-partition=none
>> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c; ./a.out
>> 2>&1
>>
>> /tmp/ccgSw6NI.lto.o: In function `main':
>> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13:
>> undefined reference to `.LASANPC0.2585'
>> collect2: error: ld returned 1 exit status
>>
>> Looks like this patch is not friendly to -flto
>
> I guess if you do:
> ...
> -  tree str_cst;
> +  tree str_cst, decl, id;
> ...
> +  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC", current_function_funcdef_no);
> +  id = get_identifier (buf);
> +  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
> +                    VAR_DECL, id, char_type_node);
> +  SET_DECL_ASSEMBLER_NAME (decl, id);
> +  TREE_ADDRESSABLE (decl) = 1;
> ...
>
> it might work even for -flto.  The problem with -flto is that the default
> set_decl_assembler_name langhook for -flto appends dot and some number to
> the non-exported names, which is undesirable here, because we already make
> sure those first numbers are unique for the whole compilation unit.
>
>         Jakub
Jakub Jelinek Nov. 1, 2013, 11:34 p.m. UTC | #7
On Fri, Nov 01, 2013 at 04:13:05PM -0700, Konstantin Serebryany wrote:
> 2013-10-XX  Kostya Serebryany  <kcc@google.com>

It is November now ;)

Looks good to me, except for a few ChangeLog issues:

>         Update to match the changed asan API.
>         * asan.c:
>         (asan_function_start): New function.

Wrong ChangeLog formatting.  The above should be:
	* asan.c (asan_function_start): New function.

>         (asan_emit_stack_protection): Update the string stored in the
>         stack red zone to match new API.  Store the PC of the current
>         function in the red zone.
>         (asan_global_struct): Update the __asan_global definition to match
>         the new API.
>         (asan_add_global): Ditto.
>         * asan.h: Declare asan_function_start.

This should be:
	* asan.h (asan_function_start): New prototype.

>         * final.c:
>         (final_start_function): Call asan_function_start.

Again, remove the first :, newline and whitespace (except for one space).

>         * sanitizer.def: Rename __asan_init_v1 to __asan_init_v3.

	* sanitizer.def (BUILT_IN_ASAN_INIT): Rename from __asan_init_v1
	to __asan_init_v3.

> 
> =========== libsanitizer/ChangeLog
> 
> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> 
>         * All source files: Merge from upstream r191666.
>         * merge.sh: Added lsan.
>         * configure.ac: Added lsan.

	* configure.ac (AC_CONFIG_FILES): Added lsan.

>         * Makefile.am: Added lsan.

	* Makefile.am (SUBDIRS): Add lsan.

>         * sanitizer_common/Makefile.am: Added lsan.

That is not what you've changed.  You've changed
	* sanitizer_common/Makefile.am (sanitizer_common_files):
and changed formatting and added a few files, but nothing related to lsan.

>         * asan/Makefile.am: Added dependency on lsan.

Again, list what you've changed there and describe the changes.

>         * lsan/Makefile.am: New file.
>         * asan/Makefile.in: Regenerate.
>         * lsan/Makefile.in: Regenerate.
>         * Makefile.in: Regenerate.
>         * configure: Regenerate.
>         * sanitizer_common/Makefile.in: Regenerate.

Ok with those changes.

	Jakub
Konstantin Serebryany Nov. 1, 2013, 11:52 p.m. UTC | #8
Fixed all.
I'll commit on Monday so that I can respond to any failures if they
appear quickly.

Thanks!

--kcc

=========== gcc/testsuite/ChangeLog

2013-11-04  Kostya Serebryany  <kcc@google.com>

        * g++.dg/asan/asan_test.cc: Update the test
        to match the fresh asan run-time.
        * c-c++-common/asan/stack-overflow-1.c: Ditto.

=========== gcc/ChangeLog

2013-11-04  Kostya Serebryany  <kcc@google.com>

        Update to match the changed asan API.
        * asan.c (asan_function_start): New function.
        (asan_emit_stack_protection): Update the string stored in the
        stack red zone to match new API.  Store the PC of the current
        function in the red zone.
        (asan_global_struct): Update the __asan_global definition to match
        the new API.
        (asan_add_global): Ditto.
        * asan.h (asan_function_start): New prototype.
        * final.c (final_start_function): Call asan_function_start.
        * sanitizer.def (BUILT_IN_ASAN_INIT): Rename __asan_init_v1 to
__asan_init_v3.

=========== libsanitizer/ChangeLog

2013-11-04  Kostya Serebryany  <kcc@google.com>

        * All source files: Merge from upstream r191666.
        * merge.sh: Added lsan.
        * configure.ac (AC_CONFIG_FILES): Added lsan.
        * Makefile.am (SUBDIRS): Added lsan.
        * sanitizer_common/Makefile.am (sanitizer_common_files): Added new fles.
        * asan/Makefile.am (asan_files): Added new files.
        (libasan_la_LIBADD): Added a dependency on lsan.
        * lsan/Makefile.am: New file.
        * asan/Makefile.in: Regenerate.
        * lsan/Makefile.in: Regenerate.
        * Makefile.in: Regenerate.
        * configure: Regenerate.
        * sanitizer_common/Makefile.in: Regenerate.

On Fri, Nov 1, 2013 at 4:34 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Nov 01, 2013 at 04:13:05PM -0700, Konstantin Serebryany wrote:
>> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>
> It is November now ;)
>
> Looks good to me, except for a few ChangeLog issues:
>
>>         Update to match the changed asan API.
>>         * asan.c:
>>         (asan_function_start): New function.
>
> Wrong ChangeLog formatting.  The above should be:
>         * asan.c (asan_function_start): New function.
>
>>         (asan_emit_stack_protection): Update the string stored in the
>>         stack red zone to match new API.  Store the PC of the current
>>         function in the red zone.
>>         (asan_global_struct): Update the __asan_global definition to match
>>         the new API.
>>         (asan_add_global): Ditto.
>>         * asan.h: Declare asan_function_start.
>
> This should be:
>         * asan.h (asan_function_start): New prototype.
>
>>         * final.c:
>>         (final_start_function): Call asan_function_start.
>
> Again, remove the first :, newline and whitespace (except for one space).
>
>>         * sanitizer.def: Rename __asan_init_v1 to __asan_init_v3.
>
>         * sanitizer.def (BUILT_IN_ASAN_INIT): Rename from __asan_init_v1
>         to __asan_init_v3.
>
>>
>> =========== libsanitizer/ChangeLog
>>
>> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>>
>>         * All source files: Merge from upstream r191666.
>>         * merge.sh: Added lsan.
>>         * configure.ac: Added lsan.
>
>         * configure.ac (AC_CONFIG_FILES): Added lsan.
>
>>         * Makefile.am: Added lsan.
>
>         * Makefile.am (SUBDIRS): Add lsan.
>
>>         * sanitizer_common/Makefile.am: Added lsan.
>
> That is not what you've changed.  You've changed
>         * sanitizer_common/Makefile.am (sanitizer_common_files):
> and changed formatting and added a few files, but nothing related to lsan.
>
>>         * asan/Makefile.am: Added dependency on lsan.
>
> Again, list what you've changed there and describe the changes.
>
>>         * lsan/Makefile.am: New file.
>>         * asan/Makefile.in: Regenerate.
>>         * lsan/Makefile.in: Regenerate.
>>         * Makefile.in: Regenerate.
>>         * configure: Regenerate.
>>         * sanitizer_common/Makefile.in: Regenerate.
>
> Ok with those changes.
>
>         Jakub
Jack Howarth Nov. 2, 2013, 5:25 p.m. UTC | #9
On Fri, Nov 01, 2013 at 04:13:05PM -0700, Konstantin Serebryany wrote:
> Jukub,
> 
> This works!
> New patch attached.

Konstantin,
   This patch, when applied on top of r204305, bootstraps fine on x86_64-apple-darwin12 but
produces a lot of regressions with...

make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m64}'"

Native configuration is x86_64-apple-darwin12.5.0

		=== g++ tests ===


Running target unix/-m64
FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test
FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O0  execution test
FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O1  execution test
FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O2  execution test
FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -fomit-frame-pointer  execution test
FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -g  execution test
FAIL: g++.dg/asan/deep-stack-uaf-1.C  -Os  execution test
FAIL: g++.dg/asan/deep-tail-call-1.C  -O0  execution test
FAIL: g++.dg/asan/deep-tail-call-1.C  -O1  execution test
FAIL: g++.dg/asan/deep-tail-call-1.C  -O2  execution test
FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -fomit-frame-pointer  execution test
FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -g  execution test
FAIL: g++.dg/asan/deep-tail-call-1.C  -Os  execution test
FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto -flto-partition=none  execution test
FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto  execution test
FAIL: g++.dg/asan/deep-thread-stack-1.C  -O0  execution test
FAIL: g++.dg/asan/deep-thread-stack-1.C  -O1  execution test
FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2  execution test
FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -fomit-frame-pointer  execution test
FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -g  execution test
FAIL: g++.dg/asan/deep-thread-stack-1.C  -Os  execution test
FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto -flto-partition=none  execution test
FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto  execution test
FAIL: g++.dg/asan/interception-failure-test-1.C  -O0  output pattern test, is ==15047==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
FAIL: g++.dg/asan/interception-failure-test-1.C  -O1  output pattern test, is ==15061==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
FAIL: g++.dg/asan/interception-failure-test-1.C  -O2  output pattern test, is ==15075==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -fomit-frame-pointer  output pattern test, is ==15090==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -g  output pattern test, is ==15104==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
FAIL: g++.dg/asan/interception-failure-test-1.C  -Os  output pattern test, is ==15118==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto -flto-partition=none  output pattern test, is ==15142==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto  output pattern test, is ==15168==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
FAIL: g++.dg/asan/large-func-test-1.C  -O0  execution test
FAIL: g++.dg/asan/large-func-test-1.C  -O1  execution test
FAIL: g++.dg/asan/large-func-test-1.C  -O2  execution test
FAIL: g++.dg/asan/large-func-test-1.C  -O3 -fomit-frame-pointer  execution test
FAIL: g++.dg/asan/large-func-test-1.C  -O3 -g  execution test
FAIL: g++.dg/asan/large-func-test-1.C  -Os  execution test
FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto -flto-partition=none  execution test
FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto  execution test
FAIL: g++.dg/asan/symbolize-callback-1.C  -O2  execution test
FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto -flto-partition=none  execution test
FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto  execution test

		=== g++ Summary ===

# of expected passes		259
# of unexpected failures	111
# of unsupported tests		132
/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC) 

		=== gcc tests ===


Running target unix/-m64
FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test

		=== gcc Summary ===

# of expected passes		178
# of unexpected failures	70
# of unsupported tests		101
/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC) 


/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC) 


Compiler version: 4.9.0 20131101 (experimental) (GCC) 
Platform: x86_64-apple-darwin12.5.0
configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9

Oddly executing...

make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m32}'"

results in no regressions on x86_64-apple-darwin12.

Native configuration is x86_64-apple-darwin12.5.0

		=== g++ tests ===


Running target unix/-m32

		=== g++ Summary ===

# of expected passes		473
# of unsupported tests		132
/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC) 

		=== gcc tests ===


Running target unix/-m32

		=== gcc Summary ===

# of expected passes		318
# of unsupported tests		101
/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC) 

		=== gfortran tests ===


Compiler version: 4.9.0 20131101 (experimental) (GCC) 
Platform: x86_64-apple-darwin12.5.0
configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9

Has this patch been test on any darwin targets?
                  Jack
ps The failures all appear to be of the form...


Executing on host: /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c   -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/  -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs  -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never   -O0  -fno-builtin-memcmp  -lm   -m64 -o ./memcmp-1.exe    (timeout = 300)
spawn /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/ -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never -O0 -fno-builtin-memcmp -lm -m64 -o ./memcmp-1.exe^M
PASS: c-c++-common/asan/memcmp-1.c  -O0  (test for excess errors)
Setting LD_LIBRARY_PATH to :/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs::/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs
spawn [open ...]^M
==23392==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test

> 
> Tested:
> make  -C gcc check-g{cc,++}
> RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp'
> make check -C gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp'
> 
> =========== gcc/testsuite/ChangeLog
> 
> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> 
>         * g++.dg/asan/asan_test.cc: Update the test
>         to match the fresh asan run-time.
>         * c-c++-common/asan/stack-overflow-1.c: Ditto.
> 
> =========== gcc/ChangeLog
> 
> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> 
>         Update to match the changed asan API.
>         * asan.c:
>         (asan_function_start): New function.
>         (asan_emit_stack_protection): Update the string stored in the
>         stack red zone to match new API.  Store the PC of the current
>         function in the red zone.
>         (asan_global_struct): Update the __asan_global definition to match
>         the new API.
>         (asan_add_global): Ditto.
>         * asan.h: Declare asan_function_start.
>         * final.c:
>         (final_start_function): Call asan_function_start.
>         * sanitizer.def: Rename __asan_init_v1 to __asan_init_v3.
> 
> =========== libsanitizer/ChangeLog
> 
> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> 
>         * All source files: Merge from upstream r191666.
>         * merge.sh: Added lsan.
>         * configure.ac: Added lsan.
>         * Makefile.am: Added lsan.
>         * sanitizer_common/Makefile.am: Added lsan.
>         * asan/Makefile.am: Added dependency on lsan.
>         * lsan/Makefile.am: New file.
>         * asan/Makefile.in: Regenerate.
>         * lsan/Makefile.in: Regenerate.
>         * Makefile.in: Regenerate.
>         * configure: Regenerate.
>         * sanitizer_common/Makefile.in: Regenerate.
> 
> On Wed, Oct 30, 2013 at 12:03 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Tue, Oct 29, 2013 at 05:15:24PM -0700, Konstantin Serebryany wrote:
> >> Actually, I guessed the flags:
> >
> > You don't have to guess them, if you look into
> > testsuite/g++/g++.log (or testsuite/gcc/gcc.log etc.), you can find them
> > there.
> >
> >>  % ../gcc-inst/bin/g++ -g -fsanitize=address -static-libasan -O2 -flto
> >> -fno-use-linker-plugin -flto-partition=none
> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c; ./a.out
> >> 2>&1
> >>
> >> /tmp/ccgSw6NI.lto.o: In function `main':
> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13:
> >> undefined reference to `.LASANPC0.2585'
> >> collect2: error: ld returned 1 exit status
> >>
> >> Looks like this patch is not friendly to -flto
> >
> > I guess if you do:
> > ...
> > -  tree str_cst;
> > +  tree str_cst, decl, id;
> > ...
> > +  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC", current_function_funcdef_no);
> > +  id = get_identifier (buf);
> > +  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
> > +                    VAR_DECL, id, char_type_node);
> > +  SET_DECL_ASSEMBLER_NAME (decl, id);
> > +  TREE_ADDRESSABLE (decl) = 1;
> > ...
> >
> > it might work even for -flto.  The problem with -flto is that the default
> > set_decl_assembler_name langhook for -flto appends dot and some number to
> > the non-exported names, which is undesirable here, because we already make
> > sure those first numbers are unique for the whole compilation unit.
> >
> >         Jakub
Konstantin Serebryany Nov. 4, 2013, 2:47 p.m. UTC | #10
+glider, our Mac expert.

Hi Jack,

This patch has not been tested on Mac and we generally do not claim
that gcc-asan is supported on Mac.
clang-asan *is* supported on Mac and our bots are green (this patch is
a merge of the sources which are regularly tested on Mac,
but the build procedure is different).

The failing assertion is weird, I haven't seen it since last year
(https://code.google.com/p/address-sanitizer/issues/detail?id=117),
but Alexander should know more.

What is your version of Mac OS?

--kcc

On Sat, Nov 2, 2013 at 10:25 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
> On Fri, Nov 01, 2013 at 04:13:05PM -0700, Konstantin Serebryany wrote:
>> Jukub,
>>
>> This works!
>> New patch attached.
>
> Konstantin,
>    This patch, when applied on top of r204305, bootstraps fine on x86_64-apple-darwin12 but
> produces a lot of regressions with...
>
> make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m64}'"
>
> Native configuration is x86_64-apple-darwin12.5.0
>
>                 === g++ tests ===
>
>
> Running target unix/-m64
> FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
> FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
> FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test
> FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O0  execution test
> FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O1  execution test
> FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O2  execution test
> FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -fomit-frame-pointer  execution test
> FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -g  execution test
> FAIL: g++.dg/asan/deep-stack-uaf-1.C  -Os  execution test
> FAIL: g++.dg/asan/deep-tail-call-1.C  -O0  execution test
> FAIL: g++.dg/asan/deep-tail-call-1.C  -O1  execution test
> FAIL: g++.dg/asan/deep-tail-call-1.C  -O2  execution test
> FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -fomit-frame-pointer  execution test
> FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -g  execution test
> FAIL: g++.dg/asan/deep-tail-call-1.C  -Os  execution test
> FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto -flto-partition=none  execution test
> FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto  execution test
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -O0  execution test
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -O1  execution test
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2  execution test
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -fomit-frame-pointer  execution test
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -g  execution test
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -Os  execution test
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto -flto-partition=none  execution test
> FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto  execution test
> FAIL: g++.dg/asan/interception-failure-test-1.C  -O0  output pattern test, is ==15047==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> FAIL: g++.dg/asan/interception-failure-test-1.C  -O1  output pattern test, is ==15061==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> FAIL: g++.dg/asan/interception-failure-test-1.C  -O2  output pattern test, is ==15075==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -fomit-frame-pointer  output pattern test, is ==15090==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -g  output pattern test, is ==15104==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> FAIL: g++.dg/asan/interception-failure-test-1.C  -Os  output pattern test, is ==15118==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto -flto-partition=none  output pattern test, is ==15142==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto  output pattern test, is ==15168==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> FAIL: g++.dg/asan/large-func-test-1.C  -O0  execution test
> FAIL: g++.dg/asan/large-func-test-1.C  -O1  execution test
> FAIL: g++.dg/asan/large-func-test-1.C  -O2  execution test
> FAIL: g++.dg/asan/large-func-test-1.C  -O3 -fomit-frame-pointer  execution test
> FAIL: g++.dg/asan/large-func-test-1.C  -O3 -g  execution test
> FAIL: g++.dg/asan/large-func-test-1.C  -Os  execution test
> FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto -flto-partition=none  execution test
> FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto  execution test
> FAIL: g++.dg/asan/symbolize-callback-1.C  -O2  execution test
> FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto -flto-partition=none  execution test
> FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto  execution test
>
>                 === g++ Summary ===
>
> # of expected passes            259
> # of unexpected failures        111
> # of unsupported tests          132
> /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC)
>
>                 === gcc tests ===
>
>
> Running target unix/-m64
> FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
> FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
> FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
> FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test
>
>                 === gcc Summary ===
>
> # of expected passes            178
> # of unexpected failures        70
> # of unsupported tests          101
> /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
>
>
> /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
>
>
> Compiler version: 4.9.0 20131101 (experimental) (GCC)
> Platform: x86_64-apple-darwin12.5.0
> configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
>
> Oddly executing...
>
> make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m32}'"
>
> results in no regressions on x86_64-apple-darwin12.
>
> Native configuration is x86_64-apple-darwin12.5.0
>
>                 === g++ tests ===
>
>
> Running target unix/-m32
>
>                 === g++ Summary ===
>
> # of expected passes            473
> # of unsupported tests          132
> /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC)
>
>                 === gcc tests ===
>
>
> Running target unix/-m32
>
>                 === gcc Summary ===
>
> # of expected passes            318
> # of unsupported tests          101
> /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
>
>                 === gfortran tests ===
>
>
> Compiler version: 4.9.0 20131101 (experimental) (GCC)
> Platform: x86_64-apple-darwin12.5.0
> configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
>
> Has this patch been test on any darwin targets?
>                   Jack
> ps The failures all appear to be of the form...
>
>
> Executing on host: /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c   -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/  -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs  -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never   -O0  -fno-builtin-memcmp  -lm   -m64 -o ./memcmp-1.exe    (timeout = 300)
> spawn /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/ -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never -O0 -fno-builtin-memcmp -lm -m64 -o ./memcmp-1.exe^M
> PASS: c-c++-common/asan/memcmp-1.c  -O0  (test for excess errors)
> Setting LD_LIBRARY_PATH to :/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs::/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs
> spawn [open ...]^M
> ==23392==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
>
>>
>> Tested:
>> make  -C gcc check-g{cc,++}
>> RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp'
>> make check -C gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp'
>>
>> =========== gcc/testsuite/ChangeLog
>>
>> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>>
>>         * g++.dg/asan/asan_test.cc: Update the test
>>         to match the fresh asan run-time.
>>         * c-c++-common/asan/stack-overflow-1.c: Ditto.
>>
>> =========== gcc/ChangeLog
>>
>> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>>
>>         Update to match the changed asan API.
>>         * asan.c:
>>         (asan_function_start): New function.
>>         (asan_emit_stack_protection): Update the string stored in the
>>         stack red zone to match new API.  Store the PC of the current
>>         function in the red zone.
>>         (asan_global_struct): Update the __asan_global definition to match
>>         the new API.
>>         (asan_add_global): Ditto.
>>         * asan.h: Declare asan_function_start.
>>         * final.c:
>>         (final_start_function): Call asan_function_start.
>>         * sanitizer.def: Rename __asan_init_v1 to __asan_init_v3.
>>
>> =========== libsanitizer/ChangeLog
>>
>> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>>
>>         * All source files: Merge from upstream r191666.
>>         * merge.sh: Added lsan.
>>         * configure.ac: Added lsan.
>>         * Makefile.am: Added lsan.
>>         * sanitizer_common/Makefile.am: Added lsan.
>>         * asan/Makefile.am: Added dependency on lsan.
>>         * lsan/Makefile.am: New file.
>>         * asan/Makefile.in: Regenerate.
>>         * lsan/Makefile.in: Regenerate.
>>         * Makefile.in: Regenerate.
>>         * configure: Regenerate.
>>         * sanitizer_common/Makefile.in: Regenerate.
>>
>> On Wed, Oct 30, 2013 at 12:03 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>> > On Tue, Oct 29, 2013 at 05:15:24PM -0700, Konstantin Serebryany wrote:
>> >> Actually, I guessed the flags:
>> >
>> > You don't have to guess them, if you look into
>> > testsuite/g++/g++.log (or testsuite/gcc/gcc.log etc.), you can find them
>> > there.
>> >
>> >>  % ../gcc-inst/bin/g++ -g -fsanitize=address -static-libasan -O2 -flto
>> >> -fno-use-linker-plugin -flto-partition=none
>> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c; ./a.out
>> >> 2>&1
>> >>
>> >> /tmp/ccgSw6NI.lto.o: In function `main':
>> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13:
>> >> undefined reference to `.LASANPC0.2585'
>> >> collect2: error: ld returned 1 exit status
>> >>
>> >> Looks like this patch is not friendly to -flto
>> >
>> > I guess if you do:
>> > ...
>> > -  tree str_cst;
>> > +  tree str_cst, decl, id;
>> > ...
>> > +  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC", current_function_funcdef_no);
>> > +  id = get_identifier (buf);
>> > +  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
>> > +                    VAR_DECL, id, char_type_node);
>> > +  SET_DECL_ASSEMBLER_NAME (decl, id);
>> > +  TREE_ADDRESSABLE (decl) = 1;
>> > ...
>> >
>> > it might work even for -flto.  The problem with -flto is that the default
>> > set_decl_assembler_name langhook for -flto appends dot and some number to
>> > the non-exported names, which is undesirable here, because we already make
>> > sure those first numbers are unique for the whole compilation unit.
>> >
>> >         Jakub
>
>
Jack Howarth Nov. 4, 2013, 4:46 p.m. UTC | #11
On Mon, Nov 04, 2013 at 06:47:13AM -0800, Konstantin Serebryany wrote:
> +glider, our Mac expert.
> 
> Hi Jack,
> 
> This patch has not been tested on Mac and we generally do not claim
> that gcc-asan is supported on Mac.
> clang-asan *is* supported on Mac and our bots are green (this patch is
> a merge of the sources which are regularly tested on Mac,
> but the build procedure is different).
> 
> The failing assertion is weird, I haven't seen it since last year
> (https://code.google.com/p/address-sanitizer/issues/detail?id=117),
> but Alexander should know more.
> 
> What is your version of Mac OS?

I am testing on MacOS X 10.8.5 with FSF gcc trunk built as...

% gcc-fsf-4.9 -v
Using built-in specs.
COLLECT_GCC=gcc-fsf-4.9
COLLECT_LTO_WRAPPER=/sw/lib/gcc4.9/libexec/gcc/x86_64-apple-darwin12.5.0/4.9.0/lto-wrapper
Target: x86_64-apple-darwin12.5.0
Configured with: ../gcc-4.9-20131101/configure --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
Thread model: posix
gcc version 4.9.0 20131101 (experimental) (GCC) 

> 
> --kcc
> 
> On Sat, Nov 2, 2013 at 10:25 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
> > On Fri, Nov 01, 2013 at 04:13:05PM -0700, Konstantin Serebryany wrote:
> >> Jukub,
> >>
> >> This works!
> >> New patch attached.
> >
> > Konstantin,
> >    This patch, when applied on top of r204305, bootstraps fine on x86_64-apple-darwin12 but
> > produces a lot of regressions with...
> >
> > make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m64}'"
> >
> > Native configuration is x86_64-apple-darwin12.5.0
> >
> >                 === g++ tests ===
> >
> >
> > Running target unix/-m64
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test
> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O0  execution test
> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O1  execution test
> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O2  execution test
> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -fomit-frame-pointer  execution test
> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -g  execution test
> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -Os  execution test
> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O0  execution test
> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O1  execution test
> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O2  execution test
> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -fomit-frame-pointer  execution test
> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -g  execution test
> > FAIL: g++.dg/asan/deep-tail-call-1.C  -Os  execution test
> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto -flto-partition=none  execution test
> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto  execution test
> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O0  execution test
> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O1  execution test
> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2  execution test
> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -fomit-frame-pointer  execution test
> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -g  execution test
> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -Os  execution test
> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto -flto-partition=none  execution test
> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto  execution test
> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O0  output pattern test, is ==15047==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O1  output pattern test, is ==15061==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O2  output pattern test, is ==15075==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -fomit-frame-pointer  output pattern test, is ==15090==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -g  output pattern test, is ==15104==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > FAIL: g++.dg/asan/interception-failure-test-1.C  -Os  output pattern test, is ==15118==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto -flto-partition=none  output pattern test, is ==15142==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto  output pattern test, is ==15168==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > FAIL: g++.dg/asan/large-func-test-1.C  -O0  execution test
> > FAIL: g++.dg/asan/large-func-test-1.C  -O1  execution test
> > FAIL: g++.dg/asan/large-func-test-1.C  -O2  execution test
> > FAIL: g++.dg/asan/large-func-test-1.C  -O3 -fomit-frame-pointer  execution test
> > FAIL: g++.dg/asan/large-func-test-1.C  -O3 -g  execution test
> > FAIL: g++.dg/asan/large-func-test-1.C  -Os  execution test
> > FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto -flto-partition=none  execution test
> > FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto  execution test
> > FAIL: g++.dg/asan/symbolize-callback-1.C  -O2  execution test
> > FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto -flto-partition=none  execution test
> > FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto  execution test
> >
> >                 === g++ Summary ===
> >
> > # of expected passes            259
> > # of unexpected failures        111
> > # of unsupported tests          132
> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC)
> >
> >                 === gcc tests ===
> >
> >
> > Running target unix/-m64
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test
> >
> >                 === gcc Summary ===
> >
> > # of expected passes            178
> > # of unexpected failures        70
> > # of unsupported tests          101
> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
> >
> >
> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
> >
> >
> > Compiler version: 4.9.0 20131101 (experimental) (GCC)
> > Platform: x86_64-apple-darwin12.5.0
> > configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
> >
> > Oddly executing...
> >
> > make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m32}'"
> >
> > results in no regressions on x86_64-apple-darwin12.
> >
> > Native configuration is x86_64-apple-darwin12.5.0
> >
> >                 === g++ tests ===
> >
> >
> > Running target unix/-m32
> >
> >                 === g++ Summary ===
> >
> > # of expected passes            473
> > # of unsupported tests          132
> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC)
> >
> >                 === gcc tests ===
> >
> >
> > Running target unix/-m32
> >
> >                 === gcc Summary ===
> >
> > # of expected passes            318
> > # of unsupported tests          101
> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
> >
> >                 === gfortran tests ===
> >
> >
> > Compiler version: 4.9.0 20131101 (experimental) (GCC)
> > Platform: x86_64-apple-darwin12.5.0
> > configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
> >
> > Has this patch been test on any darwin targets?
> >                   Jack
> > ps The failures all appear to be of the form...
> >
> >
> > Executing on host: /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c   -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/  -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs  -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never   -O0  -fno-builtin-memcmp  -lm   -m64 -o ./memcmp-1.exe    (timeout = 300)
> > spawn /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/ -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never -O0 -fno-builtin-memcmp -lm -m64 -o ./memcmp-1.exe^M
> > PASS: c-c++-common/asan/memcmp-1.c  -O0  (test for excess errors)
> > Setting LD_LIBRARY_PATH to :/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs::/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs
> > spawn [open ...]^M
> > ==23392==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
> >
> >>
> >> Tested:
> >> make  -C gcc check-g{cc,++}
> >> RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp'
> >> make check -C gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp'
> >>
> >> =========== gcc/testsuite/ChangeLog
> >>
> >> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> >>
> >>         * g++.dg/asan/asan_test.cc: Update the test
> >>         to match the fresh asan run-time.
> >>         * c-c++-common/asan/stack-overflow-1.c: Ditto.
> >>
> >> =========== gcc/ChangeLog
> >>
> >> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> >>
> >>         Update to match the changed asan API.
> >>         * asan.c:
> >>         (asan_function_start): New function.
> >>         (asan_emit_stack_protection): Update the string stored in the
> >>         stack red zone to match new API.  Store the PC of the current
> >>         function in the red zone.
> >>         (asan_global_struct): Update the __asan_global definition to match
> >>         the new API.
> >>         (asan_add_global): Ditto.
> >>         * asan.h: Declare asan_function_start.
> >>         * final.c:
> >>         (final_start_function): Call asan_function_start.
> >>         * sanitizer.def: Rename __asan_init_v1 to __asan_init_v3.
> >>
> >> =========== libsanitizer/ChangeLog
> >>
> >> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> >>
> >>         * All source files: Merge from upstream r191666.
> >>         * merge.sh: Added lsan.
> >>         * configure.ac: Added lsan.
> >>         * Makefile.am: Added lsan.
> >>         * sanitizer_common/Makefile.am: Added lsan.
> >>         * asan/Makefile.am: Added dependency on lsan.
> >>         * lsan/Makefile.am: New file.
> >>         * asan/Makefile.in: Regenerate.
> >>         * lsan/Makefile.in: Regenerate.
> >>         * Makefile.in: Regenerate.
> >>         * configure: Regenerate.
> >>         * sanitizer_common/Makefile.in: Regenerate.
> >>
> >> On Wed, Oct 30, 2013 at 12:03 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> >> > On Tue, Oct 29, 2013 at 05:15:24PM -0700, Konstantin Serebryany wrote:
> >> >> Actually, I guessed the flags:
> >> >
> >> > You don't have to guess them, if you look into
> >> > testsuite/g++/g++.log (or testsuite/gcc/gcc.log etc.), you can find them
> >> > there.
> >> >
> >> >>  % ../gcc-inst/bin/g++ -g -fsanitize=address -static-libasan -O2 -flto
> >> >> -fno-use-linker-plugin -flto-partition=none
> >> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c; ./a.out
> >> >> 2>&1
> >> >>
> >> >> /tmp/ccgSw6NI.lto.o: In function `main':
> >> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13:
> >> >> undefined reference to `.LASANPC0.2585'
> >> >> collect2: error: ld returned 1 exit status
> >> >>
> >> >> Looks like this patch is not friendly to -flto
> >> >
> >> > I guess if you do:
> >> > ...
> >> > -  tree str_cst;
> >> > +  tree str_cst, decl, id;
> >> > ...
> >> > +  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC", current_function_funcdef_no);
> >> > +  id = get_identifier (buf);
> >> > +  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
> >> > +                    VAR_DECL, id, char_type_node);
> >> > +  SET_DECL_ASSEMBLER_NAME (decl, id);
> >> > +  TREE_ADDRESSABLE (decl) = 1;
> >> > ...
> >> >
> >> > it might work even for -flto.  The problem with -flto is that the default
> >> > set_decl_assembler_name langhook for -flto appends dot and some number to
> >> > the non-exported names, which is undesirable here, because we already make
> >> > sure those first numbers are unique for the whole compilation unit.
> >> >
> >> >         Jakub
> >
> >
Konstantin Serebryany Nov. 4, 2013, 8:39 p.m. UTC | #12
On Mon, Nov 4, 2013 at 8:46 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
> On Mon, Nov 04, 2013 at 06:47:13AM -0800, Konstantin Serebryany wrote:
>> +glider, our Mac expert.
>>
>> Hi Jack,
>>
>> This patch has not been tested on Mac and we generally do not claim
>> that gcc-asan is supported on Mac.
>> clang-asan *is* supported on Mac and our bots are green (this patch is
>> a merge of the sources which are regularly tested on Mac,
>> but the build procedure is different).
>>
>> The failing assertion is weird, I haven't seen it since last year
>> (https://code.google.com/p/address-sanitizer/issues/detail?id=117),
>> but Alexander should know more.
>>
>> What is your version of Mac OS?
>
> I am testing on MacOS X 10.8.5 with FSF gcc trunk built as...

Jack,

Have you been able to figure out what's wrong?
Also, does asan from the clang trunk work for you?
I suspect that this is some kind of build/Makefile issue.
I'll commit this patch now and let's follow up on the Mac problem
separately (with help from Alexander)

--kcc

>
> % gcc-fsf-4.9 -v
> Using built-in specs.
> COLLECT_GCC=gcc-fsf-4.9
> COLLECT_LTO_WRAPPER=/sw/lib/gcc4.9/libexec/gcc/x86_64-apple-darwin12.5.0/4.9.0/lto-wrapper
> Target: x86_64-apple-darwin12.5.0
> Configured with: ../gcc-4.9-20131101/configure --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
> Thread model: posix
> gcc version 4.9.0 20131101 (experimental) (GCC)
>
>>
>> --kcc
>>
>> On Sat, Nov 2, 2013 at 10:25 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
>> > On Fri, Nov 01, 2013 at 04:13:05PM -0700, Konstantin Serebryany wrote:
>> >> Jukub,
>> >>
>> >> This works!
>> >> New patch attached.
>> >
>> > Konstantin,
>> >    This patch, when applied on top of r204305, bootstraps fine on x86_64-apple-darwin12 but
>> > produces a lot of regressions with...
>> >
>> > make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m64}'"
>> >
>> > Native configuration is x86_64-apple-darwin12.5.0
>> >
>> >                 === g++ tests ===
>> >
>> >
>> > Running target unix/-m64
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test
>> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O0  execution test
>> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O1  execution test
>> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O2  execution test
>> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -fomit-frame-pointer  execution test
>> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -g  execution test
>> > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -Os  execution test
>> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O0  execution test
>> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O1  execution test
>> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O2  execution test
>> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -fomit-frame-pointer  execution test
>> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -g  execution test
>> > FAIL: g++.dg/asan/deep-tail-call-1.C  -Os  execution test
>> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto -flto-partition=none  execution test
>> > FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto  execution test
>> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O0  execution test
>> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O1  execution test
>> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2  execution test
>> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -fomit-frame-pointer  execution test
>> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -g  execution test
>> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -Os  execution test
>> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto -flto-partition=none  execution test
>> > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto  execution test
>> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O0  output pattern test, is ==15047==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
>> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O1  output pattern test, is ==15061==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
>> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O2  output pattern test, is ==15075==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
>> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -fomit-frame-pointer  output pattern test, is ==15090==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
>> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -g  output pattern test, is ==15104==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
>> > FAIL: g++.dg/asan/interception-failure-test-1.C  -Os  output pattern test, is ==15118==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
>> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto -flto-partition=none  output pattern test, is ==15142==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
>> > FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto  output pattern test, is ==15168==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
>> > FAIL: g++.dg/asan/large-func-test-1.C  -O0  execution test
>> > FAIL: g++.dg/asan/large-func-test-1.C  -O1  execution test
>> > FAIL: g++.dg/asan/large-func-test-1.C  -O2  execution test
>> > FAIL: g++.dg/asan/large-func-test-1.C  -O3 -fomit-frame-pointer  execution test
>> > FAIL: g++.dg/asan/large-func-test-1.C  -O3 -g  execution test
>> > FAIL: g++.dg/asan/large-func-test-1.C  -Os  execution test
>> > FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto -flto-partition=none  execution test
>> > FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto  execution test
>> > FAIL: g++.dg/asan/symbolize-callback-1.C  -O2  execution test
>> > FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto -flto-partition=none  execution test
>> > FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto  execution test
>> >
>> >                 === g++ Summary ===
>> >
>> > # of expected passes            259
>> > # of unexpected failures        111
>> > # of unsupported tests          132
>> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC)
>> >
>> >                 === gcc tests ===
>> >
>> >
>> > Running target unix/-m64
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
>> > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test
>> >
>> >                 === gcc Summary ===
>> >
>> > # of expected passes            178
>> > # of unexpected failures        70
>> > # of unsupported tests          101
>> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
>> >
>> >
>> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
>> >
>> >
>> > Compiler version: 4.9.0 20131101 (experimental) (GCC)
>> > Platform: x86_64-apple-darwin12.5.0
>> > configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
>> >
>> > Oddly executing...
>> >
>> > make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m32}'"
>> >
>> > results in no regressions on x86_64-apple-darwin12.
>> >
>> > Native configuration is x86_64-apple-darwin12.5.0
>> >
>> >                 === g++ tests ===
>> >
>> >
>> > Running target unix/-m32
>> >
>> >                 === g++ Summary ===
>> >
>> > # of expected passes            473
>> > # of unsupported tests          132
>> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC)
>> >
>> >                 === gcc tests ===
>> >
>> >
>> > Running target unix/-m32
>> >
>> >                 === gcc Summary ===
>> >
>> > # of expected passes            318
>> > # of unsupported tests          101
>> > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
>> >
>> >                 === gfortran tests ===
>> >
>> >
>> > Compiler version: 4.9.0 20131101 (experimental) (GCC)
>> > Platform: x86_64-apple-darwin12.5.0
>> > configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
>> >
>> > Has this patch been test on any darwin targets?
>> >                   Jack
>> > ps The failures all appear to be of the form...
>> >
>> >
>> > Executing on host: /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c   -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/  -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs  -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never   -O0  -fno-builtin-memcmp  -lm   -m64 -o ./memcmp-1.exe    (timeout = 300)
>> > spawn /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/ -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never -O0 -fno-builtin-memcmp -lm -m64 -o ./memcmp-1.exe^M
>> > PASS: c-c++-common/asan/memcmp-1.c  -O0  (test for excess errors)
>> > Setting LD_LIBRARY_PATH to :/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs::/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs
>> > spawn [open ...]^M
>> > ==23392==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
>> > FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
>> >
>> >>
>> >> Tested:
>> >> make  -C gcc check-g{cc,++}
>> >> RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp'
>> >> make check -C gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp'
>> >>
>> >> =========== gcc/testsuite/ChangeLog
>> >>
>> >> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>> >>
>> >>         * g++.dg/asan/asan_test.cc: Update the test
>> >>         to match the fresh asan run-time.
>> >>         * c-c++-common/asan/stack-overflow-1.c: Ditto.
>> >>
>> >> =========== gcc/ChangeLog
>> >>
>> >> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>> >>
>> >>         Update to match the changed asan API.
>> >>         * asan.c:
>> >>         (asan_function_start): New function.
>> >>         (asan_emit_stack_protection): Update the string stored in the
>> >>         stack red zone to match new API.  Store the PC of the current
>> >>         function in the red zone.
>> >>         (asan_global_struct): Update the __asan_global definition to match
>> >>         the new API.
>> >>         (asan_add_global): Ditto.
>> >>         * asan.h: Declare asan_function_start.
>> >>         * final.c:
>> >>         (final_start_function): Call asan_function_start.
>> >>         * sanitizer.def: Rename __asan_init_v1 to __asan_init_v3.
>> >>
>> >> =========== libsanitizer/ChangeLog
>> >>
>> >> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
>> >>
>> >>         * All source files: Merge from upstream r191666.
>> >>         * merge.sh: Added lsan.
>> >>         * configure.ac: Added lsan.
>> >>         * Makefile.am: Added lsan.
>> >>         * sanitizer_common/Makefile.am: Added lsan.
>> >>         * asan/Makefile.am: Added dependency on lsan.
>> >>         * lsan/Makefile.am: New file.
>> >>         * asan/Makefile.in: Regenerate.
>> >>         * lsan/Makefile.in: Regenerate.
>> >>         * Makefile.in: Regenerate.
>> >>         * configure: Regenerate.
>> >>         * sanitizer_common/Makefile.in: Regenerate.
>> >>
>> >> On Wed, Oct 30, 2013 at 12:03 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>> >> > On Tue, Oct 29, 2013 at 05:15:24PM -0700, Konstantin Serebryany wrote:
>> >> >> Actually, I guessed the flags:
>> >> >
>> >> > You don't have to guess them, if you look into
>> >> > testsuite/g++/g++.log (or testsuite/gcc/gcc.log etc.), you can find them
>> >> > there.
>> >> >
>> >> >>  % ../gcc-inst/bin/g++ -g -fsanitize=address -static-libasan -O2 -flto
>> >> >> -fno-use-linker-plugin -flto-partition=none
>> >> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c; ./a.out
>> >> >> 2>&1
>> >> >>
>> >> >> /tmp/ccgSw6NI.lto.o: In function `main':
>> >> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13:
>> >> >> undefined reference to `.LASANPC0.2585'
>> >> >> collect2: error: ld returned 1 exit status
>> >> >>
>> >> >> Looks like this patch is not friendly to -flto
>> >> >
>> >> > I guess if you do:
>> >> > ...
>> >> > -  tree str_cst;
>> >> > +  tree str_cst, decl, id;
>> >> > ...
>> >> > +  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC", current_function_funcdef_no);
>> >> > +  id = get_identifier (buf);
>> >> > +  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
>> >> > +                    VAR_DECL, id, char_type_node);
>> >> > +  SET_DECL_ASSEMBLER_NAME (decl, id);
>> >> > +  TREE_ADDRESSABLE (decl) = 1;
>> >> > ...
>> >> >
>> >> > it might work even for -flto.  The problem with -flto is that the default
>> >> > set_decl_assembler_name langhook for -flto appends dot and some number to
>> >> > the non-exported names, which is undesirable here, because we already make
>> >> > sure those first numbers are unique for the whole compilation unit.
>> >> >
>> >> >         Jakub
>> >
>> >
Peter Bergner Nov. 5, 2013, 12:33 a.m. UTC | #13
On Mon, 2013-11-04 at 06:47 -0800, Konstantin Serebryany wrote:
> This patch has not been tested on Mac and we generally do not claim
> that gcc-asan is supported on Mac.
> clang-asan *is* supported on Mac and our bots are green (this patch is
> a merge of the sources which are regularly tested on Mac,
> but the build procedure is different).

The merge from upstream r191666 seems to have broken my
powerpc64-linux build.  I'm seeing:

In file included from /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:21:0:
/usr/include/asm/stat.h:31:2: error: ‘ino_t’ does not name a type
  ino_t  st_ino;
  ^
/usr/include/asm/stat.h:33:2: error: ‘nlink_t’ does not name a type
  nlink_t  st_nlink;
  ^
/usr/include/asm/stat.h:34:2: error: ‘mode_t’ does not name a type
  mode_t  st_mode;
  ^
/usr/include/asm/stat.h:39:2: error: ‘uid_t’ does not name a type
  uid_t  st_uid;
  ^
/usr/include/asm/stat.h:40:2: error: ‘gid_t’ does not name a type
  gid_t  st_gid;
  ^
/usr/include/asm/stat.h:42:2: error: ‘off_t’ does not name a type
  off_t  st_size;
  ^
/home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:29:73: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::__old_kernel_stat’
   unsigned struct___old_kernel_stat_sz = sizeof(struct __old_kernel_stat);
                                                                         ^
The problem seems to be that the RHEL6 system I am on, the linux/types.h
kernel header file doesn't define ino_t like it does on newer systems
which leads to the undefined type errors.  Digging through the other kernel
header files, I'm not really seeing another header file I can include
to get it either. :(

Peter
Konstantin Serebryany Nov. 5, 2013, 1:48 a.m. UTC | #14
Hi Peter.
Does this also mean that asan in llvm trunk is broken for Power?
We'll need to fix it there too (or, in fact, first).

--kcc

On Mon, Nov 4, 2013 at 4:33 PM, Peter Bergner <bergner@vnet.ibm.com> wrote:
> On Mon, 2013-11-04 at 06:47 -0800, Konstantin Serebryany wrote:
>> This patch has not been tested on Mac and we generally do not claim
>> that gcc-asan is supported on Mac.
>> clang-asan *is* supported on Mac and our bots are green (this patch is
>> a merge of the sources which are regularly tested on Mac,
>> but the build procedure is different).
>
> The merge from upstream r191666 seems to have broken my
> powerpc64-linux build.  I'm seeing:
>
> In file included from /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:21:0:
> /usr/include/asm/stat.h:31:2: error: ‘ino_t’ does not name a type
>   ino_t  st_ino;
>   ^
> /usr/include/asm/stat.h:33:2: error: ‘nlink_t’ does not name a type
>   nlink_t  st_nlink;
>   ^
> /usr/include/asm/stat.h:34:2: error: ‘mode_t’ does not name a type
>   mode_t  st_mode;
>   ^
> /usr/include/asm/stat.h:39:2: error: ‘uid_t’ does not name a type
>   uid_t  st_uid;
>   ^
> /usr/include/asm/stat.h:40:2: error: ‘gid_t’ does not name a type
>   gid_t  st_gid;
>   ^
> /usr/include/asm/stat.h:42:2: error: ‘off_t’ does not name a type
>   off_t  st_size;
>   ^
> /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:29:73: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::__old_kernel_stat’
>    unsigned struct___old_kernel_stat_sz = sizeof(struct __old_kernel_stat);
>                                                                          ^
> The problem seems to be that the RHEL6 system I am on, the linux/types.h
> kernel header file doesn't define ino_t like it does on newer systems
> which leads to the undefined type errors.  Digging through the other kernel
> header files, I'm not really seeing another header file I can include
> to get it either. :(
>
> Peter
>
>
Peter Bergner Nov. 5, 2013, 2:02 a.m. UTC | #15
On Mon, 2013-11-04 at 17:48 -0800, Konstantin Serebryany wrote:
> Hi Peter.
> Does this also mean that asan in llvm trunk is broken for Power?
> We'll need to fix it there too (or, in fact, first).

I'm not sure.  Bill, can you fire off a quick LLVM trunk build on
powerpc64-linux and see you see the same build error I am seeing
on gcc trunk?  Namely:

  http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00312.html

Thanks.  ...and I'll have to have you teach me how to fire off
an LLVM build one of these days so I can do this myself. :)

Peter
Bill Schmidt Nov. 5, 2013, 3:30 a.m. UTC | #16
Hi Peter,

The buildbot shows the latest LLVM ppc64 build is working ok:

http://lab.llvm.org:8011/builders/llvm-ppc64-linux2/builds/8086

This build completed about two hours ago.

Hope this helps,
Bill

On Mon, 2013-11-04 at 20:02 -0600, Peter Bergner wrote:
> On Mon, 2013-11-04 at 17:48 -0800, Konstantin Serebryany wrote:
> > Hi Peter.
> > Does this also mean that asan in llvm trunk is broken for Power?
> > We'll need to fix it there too (or, in fact, first).
> 
> I'm not sure.  Bill, can you fire off a quick LLVM trunk build on
> powerpc64-linux and see you see the same build error I am seeing
> on gcc trunk?  Namely:
> 
>   http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00312.html
> 
> Thanks.  ...and I'll have to have you teach me how to fire off
> an LLVM build one of these days so I can do this myself. :)
> 
> Peter
> 
>
H.J. Lu Nov. 5, 2013, 5:49 a.m. UTC | #17
It also breaks x32 build.


On Mon, Nov 4, 2013 at 5:48 PM, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> Hi Peter.
> Does this also mean that asan in llvm trunk is broken for Power?
> We'll need to fix it there too (or, in fact, first).
>
> --kcc
>
> On Mon, Nov 4, 2013 at 4:33 PM, Peter Bergner <bergner@vnet.ibm.com> wrote:
>> On Mon, 2013-11-04 at 06:47 -0800, Konstantin Serebryany wrote:
>>> This patch has not been tested on Mac and we generally do not claim
>>> that gcc-asan is supported on Mac.
>>> clang-asan *is* supported on Mac and our bots are green (this patch is
>>> a merge of the sources which are regularly tested on Mac,
>>> but the build procedure is different).
>>
>> The merge from upstream r191666 seems to have broken my
>> powerpc64-linux build.  I'm seeing:
>>
>> In file included from /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:21:0:
>> /usr/include/asm/stat.h:31:2: error: ‘ino_t’ does not name a type
>>   ino_t  st_ino;
>>   ^
>> /usr/include/asm/stat.h:33:2: error: ‘nlink_t’ does not name a type
>>   nlink_t  st_nlink;
>>   ^
>> /usr/include/asm/stat.h:34:2: error: ‘mode_t’ does not name a type
>>   mode_t  st_mode;
>>   ^
>> /usr/include/asm/stat.h:39:2: error: ‘uid_t’ does not name a type
>>   uid_t  st_uid;
>>   ^
>> /usr/include/asm/stat.h:40:2: error: ‘gid_t’ does not name a type
>>   gid_t  st_gid;
>>   ^
>> /usr/include/asm/stat.h:42:2: error: ‘off_t’ does not name a type
>>   off_t  st_size;
>>   ^
>> /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:29:73: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::__old_kernel_stat’
>>    unsigned struct___old_kernel_stat_sz = sizeof(struct __old_kernel_stat);
>>                                                                          ^
>> The problem seems to be that the RHEL6 system I am on, the linux/types.h
>> kernel header file doesn't define ino_t like it does on newer systems
>> which leads to the undefined type errors.  Digging through the other kernel
>> header files, I'm not really seeing another header file I can include
>> to get it either. :(
>>
>> Peter
>>
>>
Konstantin Serebryany Nov. 5, 2013, 6:35 a.m. UTC | #18
Is this the same failure or different?

On Mon, Nov 4, 2013 at 9:49 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> It also breaks x32 build.
>
>
> On Mon, Nov 4, 2013 at 5:48 PM, Konstantin Serebryany
> <konstantin.s.serebryany@gmail.com> wrote:
>> Hi Peter.
>> Does this also mean that asan in llvm trunk is broken for Power?
>> We'll need to fix it there too (or, in fact, first).
>>
>> --kcc
>>
>> On Mon, Nov 4, 2013 at 4:33 PM, Peter Bergner <bergner@vnet.ibm.com> wrote:
>>> On Mon, 2013-11-04 at 06:47 -0800, Konstantin Serebryany wrote:
>>>> This patch has not been tested on Mac and we generally do not claim
>>>> that gcc-asan is supported on Mac.
>>>> clang-asan *is* supported on Mac and our bots are green (this patch is
>>>> a merge of the sources which are regularly tested on Mac,
>>>> but the build procedure is different).
>>>
>>> The merge from upstream r191666 seems to have broken my
>>> powerpc64-linux build.  I'm seeing:
>>>
>>> In file included from /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:21:0:
>>> /usr/include/asm/stat.h:31:2: error: ‘ino_t’ does not name a type
>>>   ino_t  st_ino;
>>>   ^
>>> /usr/include/asm/stat.h:33:2: error: ‘nlink_t’ does not name a type
>>>   nlink_t  st_nlink;
>>>   ^
>>> /usr/include/asm/stat.h:34:2: error: ‘mode_t’ does not name a type
>>>   mode_t  st_mode;
>>>   ^
>>> /usr/include/asm/stat.h:39:2: error: ‘uid_t’ does not name a type
>>>   uid_t  st_uid;
>>>   ^
>>> /usr/include/asm/stat.h:40:2: error: ‘gid_t’ does not name a type
>>>   gid_t  st_gid;
>>>   ^
>>> /usr/include/asm/stat.h:42:2: error: ‘off_t’ does not name a type
>>>   off_t  st_size;
>>>   ^
>>> /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:29:73: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::__old_kernel_stat’
>>>    unsigned struct___old_kernel_stat_sz = sizeof(struct __old_kernel_stat);
>>>                                                                          ^
>>> The problem seems to be that the RHEL6 system I am on, the linux/types.h
>>> kernel header file doesn't define ino_t like it does on newer systems
>>> which leads to the undefined type errors.  Digging through the other kernel
>>> header files, I'm not really seeing another header file I can include
>>> to get it either. :(
>>>
>>> Peter
>>>
>>>
>
>
>
> --
> H.J.
Konstantin Serebryany Nov. 5, 2013, 6:43 a.m. UTC | #19
Bill,

This build does not seem to be testing any of the asan code: you need
"check-asan"

--kcc

On Mon, Nov 4, 2013 at 7:30 PM, Bill Schmidt
<wschmidt@linux.vnet.ibm.com> wrote:
> Hi Peter,
>
> The buildbot shows the latest LLVM ppc64 build is working ok:
>
> http://lab.llvm.org:8011/builders/llvm-ppc64-linux2/builds/8086
>
> This build completed about two hours ago.
>
> Hope this helps,
> Bill
>
> On Mon, 2013-11-04 at 20:02 -0600, Peter Bergner wrote:
>> On Mon, 2013-11-04 at 17:48 -0800, Konstantin Serebryany wrote:
>> > Hi Peter.
>> > Does this also mean that asan in llvm trunk is broken for Power?
>> > We'll need to fix it there too (or, in fact, first).
>>
>> I'm not sure.  Bill, can you fire off a quick LLVM trunk build on
>> powerpc64-linux and see you see the same build error I am seeing
>> on gcc trunk?  Namely:
>>
>>   http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00312.html
>>
>> Thanks.  ...and I'll have to have you teach me how to fire off
>> an LLVM build one of these days so I can do this myself. :)
>>
>> Peter
>>
>>
>
Jakub Jelinek Nov. 5, 2013, 7:19 a.m. UTC | #20
On Mon, Nov 04, 2013 at 05:48:31PM -0800, Konstantin Serebryany wrote:
> Hi Peter.
> Does this also mean that asan in llvm trunk is broken for Power?
> We'll need to fix it there too (or, in fact, first).

I bet on all targets, not just PPC.  By including kernel headers directly,
you are entering very hairy maze of kernel header issues.  So, for testing
that you probably need to grab /usr/include/{linux,asm*} trees from various
popular Linux distros (and various versions thereof), and do compile tests
against all of those.

Note, not even glibc itself includes <asm/stat.h>, so the chances of that
header actually working for you are low.  glibc instead just defines the
structures itself for each of the architectures.

	Jakub
H.J. Lu Nov. 5, 2013, 11:23 a.m. UTC | #21
It is a different failure.  There are 3 problems:

1. Hard coded 64-bit registers for pointers in x86-64 asm statements.
2. Treat WORD_SIZE == 32 as ia32 for machine state on x86-64.
3. On x86-64, assume ia32 FS system calls when LP64 is false.

H.J.
On Mon, Nov 4, 2013 at 10:35 PM, Konstantin Serebryany
<konstantin.s.serebryany@gmail.com> wrote:
> Is this the same failure or different?
>
> On Mon, Nov 4, 2013 at 9:49 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> It also breaks x32 build.
>>
>>
>> On Mon, Nov 4, 2013 at 5:48 PM, Konstantin Serebryany
>> <konstantin.s.serebryany@gmail.com> wrote:
>>> Hi Peter.
>>> Does this also mean that asan in llvm trunk is broken for Power?
>>> We'll need to fix it there too (or, in fact, first).
>>>
>>> --kcc
>>>
>>> On Mon, Nov 4, 2013 at 4:33 PM, Peter Bergner <bergner@vnet.ibm.com> wrote:
>>>> On Mon, 2013-11-04 at 06:47 -0800, Konstantin Serebryany wrote:
>>>>> This patch has not been tested on Mac and we generally do not claim
>>>>> that gcc-asan is supported on Mac.
>>>>> clang-asan *is* supported on Mac and our bots are green (this patch is
>>>>> a merge of the sources which are regularly tested on Mac,
>>>>> but the build procedure is different).
>>>>
>>>> The merge from upstream r191666 seems to have broken my
>>>> powerpc64-linux build.  I'm seeing:
>>>>
>>>> In file included from /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:21:0:
>>>> /usr/include/asm/stat.h:31:2: error: ‘ino_t’ does not name a type
>>>>   ino_t  st_ino;
>>>>   ^
>>>> /usr/include/asm/stat.h:33:2: error: ‘nlink_t’ does not name a type
>>>>   nlink_t  st_nlink;
>>>>   ^
>>>> /usr/include/asm/stat.h:34:2: error: ‘mode_t’ does not name a type
>>>>   mode_t  st_mode;
>>>>   ^
>>>> /usr/include/asm/stat.h:39:2: error: ‘uid_t’ does not name a type
>>>>   uid_t  st_uid;
>>>>   ^
>>>> /usr/include/asm/stat.h:40:2: error: ‘gid_t’ does not name a type
>>>>   gid_t  st_gid;
>>>>   ^
>>>> /usr/include/asm/stat.h:42:2: error: ‘off_t’ does not name a type
>>>>   off_t  st_size;
>>>>   ^
>>>> /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:29:73: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::__old_kernel_stat’
>>>>    unsigned struct___old_kernel_stat_sz = sizeof(struct __old_kernel_stat);
>>>>                                                                          ^
>>>> The problem seems to be that the RHEL6 system I am on, the linux/types.h
>>>> kernel header file doesn't define ino_t like it does on newer systems
>>>> which leads to the undefined type errors.  Digging through the other kernel
>>>> header files, I'm not really seeing another header file I can include
>>>> to get it either. :(
>>>>
>>>> Peter
>>>>
>>>>
>>
>>
>>
>> --
>> H.J.
H.J. Lu Nov. 5, 2013, 1:24 p.m. UTC | #22
Another problem is internal_syscall casts pointers to
uint64.  It doesn't work for x32 since 32-bit pointers are
signed extended to int64.  We can need to cast pointer
to uptr first.

On Tue, Nov 5, 2013 at 3:23 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> It is a different failure.  There are 3 problems:
>
> 1. Hard coded 64-bit registers for pointers in x86-64 asm statements.
> 2. Treat WORD_SIZE == 32 as ia32 for machine state on x86-64.
> 3. On x86-64, assume ia32 FS system calls when LP64 is false.
>
> H.J.
> On Mon, Nov 4, 2013 at 10:35 PM, Konstantin Serebryany
> <konstantin.s.serebryany@gmail.com> wrote:
>> Is this the same failure or different?
>>
>> On Mon, Nov 4, 2013 at 9:49 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> It also breaks x32 build.
>>>
>>>
>>> On Mon, Nov 4, 2013 at 5:48 PM, Konstantin Serebryany
>>> <konstantin.s.serebryany@gmail.com> wrote:
>>>> Hi Peter.
>>>> Does this also mean that asan in llvm trunk is broken for Power?
>>>> We'll need to fix it there too (or, in fact, first).
>>>>
>>>> --kcc
>>>>
>>>> On Mon, Nov 4, 2013 at 4:33 PM, Peter Bergner <bergner@vnet.ibm.com> wrote:
>>>>> On Mon, 2013-11-04 at 06:47 -0800, Konstantin Serebryany wrote:
>>>>>> This patch has not been tested on Mac and we generally do not claim
>>>>>> that gcc-asan is supported on Mac.
>>>>>> clang-asan *is* supported on Mac and our bots are green (this patch is
>>>>>> a merge of the sources which are regularly tested on Mac,
>>>>>> but the build procedure is different).
>>>>>
>>>>> The merge from upstream r191666 seems to have broken my
>>>>> powerpc64-linux build.  I'm seeing:
>>>>>
>>>>> In file included from /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:21:0:
>>>>> /usr/include/asm/stat.h:31:2: error: ‘ino_t’ does not name a type
>>>>>   ino_t  st_ino;
>>>>>   ^
>>>>> /usr/include/asm/stat.h:33:2: error: ‘nlink_t’ does not name a type
>>>>>   nlink_t  st_nlink;
>>>>>   ^
>>>>> /usr/include/asm/stat.h:34:2: error: ‘mode_t’ does not name a type
>>>>>   mode_t  st_mode;
>>>>>   ^
>>>>> /usr/include/asm/stat.h:39:2: error: ‘uid_t’ does not name a type
>>>>>   uid_t  st_uid;
>>>>>   ^
>>>>> /usr/include/asm/stat.h:40:2: error: ‘gid_t’ does not name a type
>>>>>   gid_t  st_gid;
>>>>>   ^
>>>>> /usr/include/asm/stat.h:42:2: error: ‘off_t’ does not name a type
>>>>>   off_t  st_size;
>>>>>   ^
>>>>> /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:29:73: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::__old_kernel_stat’
>>>>>    unsigned struct___old_kernel_stat_sz = sizeof(struct __old_kernel_stat);
>>>>>                                                                          ^
>>>>> The problem seems to be that the RHEL6 system I am on, the linux/types.h
>>>>> kernel header file doesn't define ino_t like it does on newer systems
>>>>> which leads to the undefined type errors.  Digging through the other kernel
>>>>> header files, I'm not really seeing another header file I can include
>>>>> to get it either. :(
>>>>>
>>>>> Peter
>>>>>
>>>>>
>>>
>>>
>>>
>>> --
>>> H.J.
>
>
>
> --
> H.J.
Richard Biener Nov. 5, 2013, 1:28 p.m. UTC | #23
On Tue, Nov 5, 2013 at 2:24 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> Another problem is internal_syscall casts pointers to
> uint64.  It doesn't work for x32 since 32-bit pointers are
> signed extended to int64.  We can need to cast pointer
> to uptr first.

Another issue is that it breaks with 2.6.32 kernel headers on x86_64:

219:24: warning: missing initializer for member
               'kernel_timeval::tv_sec' [-Wmissing-field-initializers]
               kernel_timeval tv = {};

and thus bootstrap breaks for me.

Richard.

> On Tue, Nov 5, 2013 at 3:23 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> It is a different failure.  There are 3 problems:
>>
>> 1. Hard coded 64-bit registers for pointers in x86-64 asm statements.
>> 2. Treat WORD_SIZE == 32 as ia32 for machine state on x86-64.
>> 3. On x86-64, assume ia32 FS system calls when LP64 is false.
>>
>> H.J.
>> On Mon, Nov 4, 2013 at 10:35 PM, Konstantin Serebryany
>> <konstantin.s.serebryany@gmail.com> wrote:
>>> Is this the same failure or different?
>>>
>>> On Mon, Nov 4, 2013 at 9:49 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> It also breaks x32 build.
>>>>
>>>>
>>>> On Mon, Nov 4, 2013 at 5:48 PM, Konstantin Serebryany
>>>> <konstantin.s.serebryany@gmail.com> wrote:
>>>>> Hi Peter.
>>>>> Does this also mean that asan in llvm trunk is broken for Power?
>>>>> We'll need to fix it there too (or, in fact, first).
>>>>>
>>>>> --kcc
>>>>>
>>>>> On Mon, Nov 4, 2013 at 4:33 PM, Peter Bergner <bergner@vnet.ibm.com> wrote:
>>>>>> On Mon, 2013-11-04 at 06:47 -0800, Konstantin Serebryany wrote:
>>>>>>> This patch has not been tested on Mac and we generally do not claim
>>>>>>> that gcc-asan is supported on Mac.
>>>>>>> clang-asan *is* supported on Mac and our bots are green (this patch is
>>>>>>> a merge of the sources which are regularly tested on Mac,
>>>>>>> but the build procedure is different).
>>>>>>
>>>>>> The merge from upstream r191666 seems to have broken my
>>>>>> powerpc64-linux build.  I'm seeing:
>>>>>>
>>>>>> In file included from /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:21:0:
>>>>>> /usr/include/asm/stat.h:31:2: error: ‘ino_t’ does not name a type
>>>>>>   ino_t  st_ino;
>>>>>>   ^
>>>>>> /usr/include/asm/stat.h:33:2: error: ‘nlink_t’ does not name a type
>>>>>>   nlink_t  st_nlink;
>>>>>>   ^
>>>>>> /usr/include/asm/stat.h:34:2: error: ‘mode_t’ does not name a type
>>>>>>   mode_t  st_mode;
>>>>>>   ^
>>>>>> /usr/include/asm/stat.h:39:2: error: ‘uid_t’ does not name a type
>>>>>>   uid_t  st_uid;
>>>>>>   ^
>>>>>> /usr/include/asm/stat.h:40:2: error: ‘gid_t’ does not name a type
>>>>>>   gid_t  st_gid;
>>>>>>   ^
>>>>>> /usr/include/asm/stat.h:42:2: error: ‘off_t’ does not name a type
>>>>>>   off_t  st_size;
>>>>>>   ^
>>>>>> /home/bergner/gcc/gcc-fsf-mainline-base/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:29:73: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::__old_kernel_stat’
>>>>>>    unsigned struct___old_kernel_stat_sz = sizeof(struct __old_kernel_stat);
>>>>>>                                                                          ^
>>>>>> The problem seems to be that the RHEL6 system I am on, the linux/types.h
>>>>>> kernel header file doesn't define ino_t like it does on newer systems
>>>>>> which leads to the undefined type errors.  Digging through the other kernel
>>>>>> header files, I'm not really seeing another header file I can include
>>>>>> to get it either. :(
>>>>>>
>>>>>> Peter
>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> H.J.
>>
>>
>>
>> --
>> H.J.
>
>
>
> --
> H.J.
Bill Schmidt Nov. 5, 2013, 2:31 p.m. UTC | #24
Hi Kostya,

As an aside, all of these asan tests have failed on
powerpc64le-unknown-linux-gnu since we began testing that target.  I
have not yet had time to investigate why.  Do you think there may be an
implicit or explicit assumption anywhere that PowerPC64 is big endian?
This is generally not safe to assume.  Anyway, I hope it's something
easy like that, and thought you might have an idea.

Thanks,
Bill

On Mon, 2013-11-04 at 11:46 -0500, Jack Howarth wrote:
> On Mon, Nov 04, 2013 at 06:47:13AM -0800, Konstantin Serebryany wrote:
> > +glider, our Mac expert.
> > 
> > Hi Jack,
> > 
> > This patch has not been tested on Mac and we generally do not claim
> > that gcc-asan is supported on Mac.
> > clang-asan *is* supported on Mac and our bots are green (this patch is
> > a merge of the sources which are regularly tested on Mac,
> > but the build procedure is different).
> > 
> > The failing assertion is weird, I haven't seen it since last year
> > (https://code.google.com/p/address-sanitizer/issues/detail?id=117),
> > but Alexander should know more.
> > 
> > What is your version of Mac OS?
> 
> I am testing on MacOS X 10.8.5 with FSF gcc trunk built as...
> 
> % gcc-fsf-4.9 -v
> Using built-in specs.
> COLLECT_GCC=gcc-fsf-4.9
> COLLECT_LTO_WRAPPER=/sw/lib/gcc4.9/libexec/gcc/x86_64-apple-darwin12.5.0/4.9.0/lto-wrapper
> Target: x86_64-apple-darwin12.5.0
> Configured with: ../gcc-4.9-20131101/configure --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
> Thread model: posix
> gcc version 4.9.0 20131101 (experimental) (GCC) 
> 
> > 
> > --kcc
> > 
> > On Sat, Nov 2, 2013 at 10:25 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
> > > On Fri, Nov 01, 2013 at 04:13:05PM -0700, Konstantin Serebryany wrote:
> > >> Jukub,
> > >>
> > >> This works!
> > >> New patch attached.
> > >
> > > Konstantin,
> > >    This patch, when applied on top of r204305, bootstraps fine on x86_64-apple-darwin12 but
> > > produces a lot of regressions with...
> > >
> > > make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m64}'"
> > >
> > > Native configuration is x86_64-apple-darwin12.5.0
> > >
> > >                 === g++ tests ===
> > >
> > >
> > > Running target unix/-m64
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test
> > > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O0  execution test
> > > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O1  execution test
> > > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O2  execution test
> > > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -fomit-frame-pointer  execution test
> > > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -O3 -g  execution test
> > > FAIL: g++.dg/asan/deep-stack-uaf-1.C  -Os  execution test
> > > FAIL: g++.dg/asan/deep-tail-call-1.C  -O0  execution test
> > > FAIL: g++.dg/asan/deep-tail-call-1.C  -O1  execution test
> > > FAIL: g++.dg/asan/deep-tail-call-1.C  -O2  execution test
> > > FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -fomit-frame-pointer  execution test
> > > FAIL: g++.dg/asan/deep-tail-call-1.C  -O3 -g  execution test
> > > FAIL: g++.dg/asan/deep-tail-call-1.C  -Os  execution test
> > > FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto -flto-partition=none  execution test
> > > FAIL: g++.dg/asan/deep-tail-call-1.C  -O2 -flto  execution test
> > > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O0  execution test
> > > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O1  execution test
> > > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2  execution test
> > > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -fomit-frame-pointer  execution test
> > > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O3 -g  execution test
> > > FAIL: g++.dg/asan/deep-thread-stack-1.C  -Os  execution test
> > > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto -flto-partition=none  execution test
> > > FAIL: g++.dg/asan/deep-thread-stack-1.C  -O2 -flto  execution test
> > > FAIL: g++.dg/asan/interception-failure-test-1.C  -O0  output pattern test, is ==15047==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > > FAIL: g++.dg/asan/interception-failure-test-1.C  -O1  output pattern test, is ==15061==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > > FAIL: g++.dg/asan/interception-failure-test-1.C  -O2  output pattern test, is ==15075==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > > FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -fomit-frame-pointer  output pattern test, is ==15090==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > > FAIL: g++.dg/asan/interception-failure-test-1.C  -O3 -g  output pattern test, is ==15104==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > > FAIL: g++.dg/asan/interception-failure-test-1.C  -Os  output pattern test, is ==15118==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > > FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto -flto-partition=none  output pattern test, is ==15142==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > > FAIL: g++.dg/asan/interception-failure-test-1.C  -O2 -flto  output pattern test, is ==15168==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > > FAIL: g++.dg/asan/large-func-test-1.C  -O0  execution test
> > > FAIL: g++.dg/asan/large-func-test-1.C  -O1  execution test
> > > FAIL: g++.dg/asan/large-func-test-1.C  -O2  execution test
> > > FAIL: g++.dg/asan/large-func-test-1.C  -O3 -fomit-frame-pointer  execution test
> > > FAIL: g++.dg/asan/large-func-test-1.C  -O3 -g  execution test
> > > FAIL: g++.dg/asan/large-func-test-1.C  -Os  execution test
> > > FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto -flto-partition=none  execution test
> > > FAIL: g++.dg/asan/large-func-test-1.C  -O2 -flto  execution test
> > > FAIL: g++.dg/asan/symbolize-callback-1.C  -O2  execution test
> > > FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto -flto-partition=none  execution test
> > > FAIL: g++.dg/asan/symbolize-callback-1.C  -O2 -flto  execution test
> > >
> > >                 === g++ Summary ===
> > >
> > > # of expected passes            259
> > > # of unexpected failures        111
> > > # of unsupported tests          132
> > > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC)
> > >
> > >                 === gcc tests ===
> > >
> > >
> > > Running target unix/-m64
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/global-overflow-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/heap-overflow-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/null-deref-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/sanity-check-pure-c-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/sleep-before-dying-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/stack-overflow-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/strip-path-prefix-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/strncpy-overflow-1.c  -O2 -flto  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O0  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O1  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O2  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -fomit-frame-pointer  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O3 -g  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -Os  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto -flto-partition=none  execution test
> > > FAIL: c-c++-common/asan/use-after-free-1.c  -O2 -flto  execution test
> > >
> > >                 === gcc Summary ===
> > >
> > > # of expected passes            178
> > > # of unexpected failures        70
> > > # of unsupported tests          101
> > > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
> > >
> > >
> > > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
> > >
> > >
> > > Compiler version: 4.9.0 20131101 (experimental) (GCC)
> > > Platform: x86_64-apple-darwin12.5.0
> > > configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
> > >
> > > Oddly executing...
> > >
> > > make -k check RUNTESTFLAGS="asan.exp --target_board=unix'{-m32}'"
> > >
> > > results in no regressions on x86_64-apple-darwin12.
> > >
> > > Native configuration is x86_64-apple-darwin12.5.0
> > >
> > >                 === g++ tests ===
> > >
> > >
> > > Running target unix/-m32
> > >
> > >                 === g++ Summary ===
> > >
> > > # of expected passes            473
> > > # of unsupported tests          132
> > > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/testsuite/g++/../../xg++  version 4.9.0 20131101 (experimental) (GCC)
> > >
> > >                 === gcc tests ===
> > >
> > >
> > > Running target unix/-m32
> > >
> > >                 === gcc Summary ===
> > >
> > > # of expected passes            318
> > > # of unsupported tests          101
> > > /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc  version 4.9.0 20131101 (experimental) (GCC)
> > >
> > >                 === gfortran tests ===
> > >
> > >
> > > Compiler version: 4.9.0 20131101 (experimental) (GCC)
> > > Platform: x86_64-apple-darwin12.5.0
> > > configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.9 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.9/info --enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-isl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --enable-checking=yes --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.9
> > >
> > > Has this patch been test on any darwin targets?
> > >                   Jack
> > > ps The failures all appear to be of the form...
> > >
> > >
> > > Executing on host: /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c   -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/  -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs  -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never   -O0  -fno-builtin-memcmp  -lm   -m64 -o ./memcmp-1.exe    (timeout = 300)
> > > spawn /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/xgcc -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc/ /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20131101/gcc/testsuite/c-c++-common/asan/memcmp-1.c -B/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/ -L/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs -fsanitize=address -g -fno-diagnostics-show-caret -fdiagnostics-color=never -O0 -fno-builtin-memcmp -lm -m64 -o ./memcmp-1.exe^M
> > > PASS: c-c++-common/asan/memcmp-1.c  -O0  (test for excess errors)
> > > Setting LD_LIBRARY_PATH to :/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs::/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/gcc:/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/./libsanitizer/asan/.libs
> > > spawn [open ...]^M
> > > ==23392==AddressSanitizer CHECK failed: ../../../../gcc-4.9-20131101/libsanitizer/sanitizer_common/sanitizer_mac.cc:146 "((env_ptr)) != (0)" (0x0, 0x0)
> > > FAIL: c-c++-common/asan/memcmp-1.c  -O0  execution test
> > >
> > >>
> > >> Tested:
> > >> make  -C gcc check-g{cc,++}
> > >> RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} asan.exp'
> > >> make check -C gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} ubsan.exp'
> > >>
> > >> =========== gcc/testsuite/ChangeLog
> > >>
> > >> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> > >>
> > >>         * g++.dg/asan/asan_test.cc: Update the test
> > >>         to match the fresh asan run-time.
> > >>         * c-c++-common/asan/stack-overflow-1.c: Ditto.
> > >>
> > >> =========== gcc/ChangeLog
> > >>
> > >> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> > >>
> > >>         Update to match the changed asan API.
> > >>         * asan.c:
> > >>         (asan_function_start): New function.
> > >>         (asan_emit_stack_protection): Update the string stored in the
> > >>         stack red zone to match new API.  Store the PC of the current
> > >>         function in the red zone.
> > >>         (asan_global_struct): Update the __asan_global definition to match
> > >>         the new API.
> > >>         (asan_add_global): Ditto.
> > >>         * asan.h: Declare asan_function_start.
> > >>         * final.c:
> > >>         (final_start_function): Call asan_function_start.
> > >>         * sanitizer.def: Rename __asan_init_v1 to __asan_init_v3.
> > >>
> > >> =========== libsanitizer/ChangeLog
> > >>
> > >> 2013-10-XX  Kostya Serebryany  <kcc@google.com>
> > >>
> > >>         * All source files: Merge from upstream r191666.
> > >>         * merge.sh: Added lsan.
> > >>         * configure.ac: Added lsan.
> > >>         * Makefile.am: Added lsan.
> > >>         * sanitizer_common/Makefile.am: Added lsan.
> > >>         * asan/Makefile.am: Added dependency on lsan.
> > >>         * lsan/Makefile.am: New file.
> > >>         * asan/Makefile.in: Regenerate.
> > >>         * lsan/Makefile.in: Regenerate.
> > >>         * Makefile.in: Regenerate.
> > >>         * configure: Regenerate.
> > >>         * sanitizer_common/Makefile.in: Regenerate.
> > >>
> > >> On Wed, Oct 30, 2013 at 12:03 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > >> > On Tue, Oct 29, 2013 at 05:15:24PM -0700, Konstantin Serebryany wrote:
> > >> >> Actually, I guessed the flags:
> > >> >
> > >> > You don't have to guess them, if you look into
> > >> > testsuite/g++/g++.log (or testsuite/gcc/gcc.log etc.), you can find them
> > >> > there.
> > >> >
> > >> >>  % ../gcc-inst/bin/g++ -g -fsanitize=address -static-libasan -O2 -flto
> > >> >> -fno-use-linker-plugin -flto-partition=none
> > >> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c; ./a.out
> > >> >> 2>&1
> > >> >>
> > >> >> /tmp/ccgSw6NI.lto.o: In function `main':
> > >> >> ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13:
> > >> >> undefined reference to `.LASANPC0.2585'
> > >> >> collect2: error: ld returned 1 exit status
> > >> >>
> > >> >> Looks like this patch is not friendly to -flto
> > >> >
> > >> > I guess if you do:
> > >> > ...
> > >> > -  tree str_cst;
> > >> > +  tree str_cst, decl, id;
> > >> > ...
> > >> > +  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC", current_function_funcdef_no);
> > >> > +  id = get_identifier (buf);
> > >> > +  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
> > >> > +                    VAR_DECL, id, char_type_node);
> > >> > +  SET_DECL_ASSEMBLER_NAME (decl, id);
> > >> > +  TREE_ADDRESSABLE (decl) = 1;
> > >> > ...
> > >> >
> > >> > it might work even for -flto.  The problem with -flto is that the default
> > >> > set_decl_assembler_name langhook for -flto appends dot and some number to
> > >> > the non-exported names, which is undesirable here, because we already make
> > >> > sure those first numbers are unique for the whole compilation unit.
> > >> >
> > >> >         Jakub
> > >
> > >
>
Peter Bergner Nov. 5, 2013, 3:57 p.m. UTC | #25
On Tue, 2013-11-05 at 08:19 +0100, Jakub Jelinek wrote:
> On Mon, Nov 04, 2013 at 05:48:31PM -0800, Konstantin Serebryany wrote:
> > Hi Peter.
> > Does this also mean that asan in llvm trunk is broken for Power?
> > We'll need to fix it there too (or, in fact, first).
> 
> I bet on all targets, not just PPC.  By including kernel headers directly,
> you are entering very hairy maze of kernel header issues.  So, for testing
> that you probably need to grab /usr/include/{linux,asm*} trees from various
> popular Linux distros (and various versions thereof), and do compile tests
> against all of those.
> 
> Note, not even glibc itself includes <asm/stat.h>, so the chances of that
> header actually working for you are low.  glibc instead just defines the
> structures itself for each of the architectures.

I have to agree, including kernel header files is always frowned upon
and very risky.  Jakub, do you think we should be doing the same thing
here that glibc does, namely having libsanitizer defining its own
structures?

Peter
Peter Bergner Nov. 5, 2013, 6:07 p.m. UTC | #26
On Tue, 2013-11-05 at 09:57 -0600, Peter Bergner wrote:
> On Tue, 2013-11-05 at 08:19 +0100, Jakub Jelinek wrote:
> > Note, not even glibc itself includes <asm/stat.h>, so the chances of that
> > header actually working for you are low.  glibc instead just defines the
> > structures itself for each of the architectures.
> 
> I have to agree, including kernel header files is always frowned upon
> and very risky.  Jakub, do you think we should be doing the same thing
> here that glibc does, namely having libsanitizer defining its own
> structures?

One other problem is the use of __old_kernel_stat in the libsanitizer
sources.  The PPC64 kernel was created after the change to the current
stat, so it doesn't define __old_kernel_stat since it never had one.

Peter
Evgenii Stepanov Nov. 5, 2013, 6:17 p.m. UTC | #27
On Tue, Nov 5, 2013 at 10:07 AM, Peter Bergner <bergner@vnet.ibm.com> wrote:
> On Tue, 2013-11-05 at 09:57 -0600, Peter Bergner wrote:
>> On Tue, 2013-11-05 at 08:19 +0100, Jakub Jelinek wrote:
>> > Note, not even glibc itself includes <asm/stat.h>, so the chances of that
>> > header actually working for you are low.  glibc instead just defines the
>> > structures itself for each of the architectures.
>>
>> I have to agree, including kernel header files is always frowned upon
>> and very risky.  Jakub, do you think we should be doing the same thing
>> here that glibc does, namely having libsanitizer defining its own
>> structures?
>
> One other problem is the use of __old_kernel_stat in the libsanitizer
> sources.  The PPC64 kernel was created after the change to the current
> stat, so it doesn't define __old_kernel_stat since it never had one.

In fact, we do define our own structures. Kernel headers are limited
to one or two files just to verify that our definitions are binary
compatible.

__old_kernel_stat issue must be solvable with a reasonable amount of #ifdefs.
Jakub Jelinek Nov. 5, 2013, 6:45 p.m. UTC | #28
On Tue, Nov 05, 2013 at 10:17:09AM -0800, Evgeniy Stepanov wrote:
> On Tue, Nov 5, 2013 at 10:07 AM, Peter Bergner <bergner@vnet.ibm.com> wrote:
> > On Tue, 2013-11-05 at 09:57 -0600, Peter Bergner wrote:
> >> On Tue, 2013-11-05 at 08:19 +0100, Jakub Jelinek wrote:
> >> > Note, not even glibc itself includes <asm/stat.h>, so the chances of that
> >> > header actually working for you are low.  glibc instead just defines the
> >> > structures itself for each of the architectures.
> >>
> >> I have to agree, including kernel header files is always frowned upon
> >> and very risky.  Jakub, do you think we should be doing the same thing
> >> here that glibc does, namely having libsanitizer defining its own
> >> structures?
> >
> > One other problem is the use of __old_kernel_stat in the libsanitizer
> > sources.  The PPC64 kernel was created after the change to the current
> > stat, so it doesn't define __old_kernel_stat since it never had one.
> 
> In fact, we do define our own structures. Kernel headers are limited
> to one or two files just to verify that our definitions are binary
> compatible.
> 
> __old_kernel_stat issue must be solvable with a reasonable amount of #ifdefs.

Perhaps that verification should be done instead just by testing this,
say by calling both libasan stat* and corresponding glibc stat* on the same
files and comparing?  You can do the latter through say dlsym/dlvsym.

Some kernel headers are really better to be avoided, because, as you could
already partly see now or in the past, some of them were never really
properly tested to be usable from userland, or at least not in every distro
and it's version out there.  Kernel headers used by glibc itself internally
have a higher chance of working than others.

	Jakub
Evgenii Stepanov Nov. 5, 2013, 9:49 p.m. UTC | #29
On Tue, Nov 5, 2013 at 10:45 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Nov 05, 2013 at 10:17:09AM -0800, Evgeniy Stepanov wrote:
>> On Tue, Nov 5, 2013 at 10:07 AM, Peter Bergner <bergner@vnet.ibm.com> wrote:
>> > On Tue, 2013-11-05 at 09:57 -0600, Peter Bergner wrote:
>> >> On Tue, 2013-11-05 at 08:19 +0100, Jakub Jelinek wrote:
>> >> > Note, not even glibc itself includes <asm/stat.h>, so the chances of that
>> >> > header actually working for you are low.  glibc instead just defines the
>> >> > structures itself for each of the architectures.
>> >>
>> >> I have to agree, including kernel header files is always frowned upon
>> >> and very risky.  Jakub, do you think we should be doing the same thing
>> >> here that glibc does, namely having libsanitizer defining its own
>> >> structures?
>> >
>> > One other problem is the use of __old_kernel_stat in the libsanitizer
>> > sources.  The PPC64 kernel was created after the change to the current
>> > stat, so it doesn't define __old_kernel_stat since it never had one.
>>
>> In fact, we do define our own structures. Kernel headers are limited
>> to one or two files just to verify that our definitions are binary
>> compatible.
>>
>> __old_kernel_stat issue must be solvable with a reasonable amount of #ifdefs.
>
> Perhaps that verification should be done instead just by testing this,
> say by calling both libasan stat* and corresponding glibc stat* on the same
> files and comparing?  You can do the latter through say dlsym/dlvsym.
>
> Some kernel headers are really better to be avoided, because, as you could
> already partly see now or in the past, some of them were never really
> properly tested to be usable from userland, or at least not in every distro
> and it's version out there.  Kernel headers used by glibc itself internally
> have a higher chance of working than others.

This way we can't test kernel interfaces that are not used in glibc,
like linux aio.

Most of our team is travelling, and we won't be able to submit a
proper fix until next week. Is this blocking anyone? Are you OK with
disabling broken parts with #ifdefs for now? Most of this is used in
the interceptors, and they can be disabled on an individual basis.
Jakub Jelinek Nov. 6, 2013, 11:53 a.m. UTC | #30
On Tue, Nov 05, 2013 at 01:49:43PM -0800, Evgeniy Stepanov wrote:
> This way we can't test kernel interfaces that are not used in glibc,
> like linux aio.

So you just test what you can test.  Why do you need to intercept kernel
aio when hardly anything uses it?  Also, what is the reason why say
stat* interceptors couldn't just use the glibc stat* (using dlsym
obtained pointers) and just do some work before and/or after)?

> Most of our team is travelling, and we won't be able to submit a
> proper fix until next week. Is this blocking anyone? Are you OK with
> disabling broken parts with #ifdefs for now? Most of this is used in
> the interceptors, and they can be disabled on an individual basis.

Bootstrap failures are certainly blocking lots of people, so if you could
disable known problematic parts with #ifdefs for now and resolve later, it
would be great.

	Jakub
Evgenii Stepanov Nov. 7, 2013, 5:46 a.m. UTC | #31
On Wed, Nov 6, 2013 at 3:53 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Nov 05, 2013 at 01:49:43PM -0800, Evgeniy Stepanov wrote:
>> This way we can't test kernel interfaces that are not used in glibc,
>> like linux aio.
>
> So you just test what you can test.  Why do you need to intercept kernel
> aio when hardly anything uses it?  Also, what is the reason why say
> stat* interceptors couldn't just use the glibc stat* (using dlsym
> obtained pointers) and just do some work before and/or after)?

stat* can, should, and do use glibc stat*. But we also have stat*
system call handlers. Those are not wired anywhere and provided as
annotations for any system calls used directly from the user code.

We need aio handlers for MSan, where not having them results in false
positives. ASan gets them for free.

>
>> Most of our team is travelling, and we won't be able to submit a
>> proper fix until next week. Is this blocking anyone? Are you OK with
>> disabling broken parts with #ifdefs for now? Most of this is used in
>> the interceptors, and they can be disabled on an individual basis.
>
> Bootstrap failures are certainly blocking lots of people, so if you could
> disable known problematic parts with #ifdefs for now and resolve later, it
> would be great.
>
>         Jakub
Michael Meissner Nov. 12, 2013, 5:37 p.m. UTC | #32
It has been a week since the libsanitizer patches were checked in, which broke
the PowerPC64 Linux system along with others (PR 59009 for powerpc).  Please
revert these patches while you are working on proper fixes for all of the hosts
and targets.

Quoting from the GCC development plan:

Patch Reversion

If a patch is committed which introduces a regression on any target which the
Steering Committee considers to be important and if:

the problem is reported to the original poster; 48 hours pass without the
original poster or any other party indicating that a fix will be forthcoming in
the very near future; two people with write privileges to the affected area of
the compiler determine that the best course of action is to revert the patch;
then they may revert the patch.

(The list of important targets will be revised at the beginning of each release
cycle, if necessary, and is part of the release criteria.)

After the patch has been reverted, the poster may appeal the decision to the
Steering Committee.

Note that no distinction is made between patches which are themselves buggy and
patches that expose latent bugs elsewhere in the compiler.
Kostya Serebryany Nov. 12, 2013, 5:41 p.m. UTC | #33
[plain text]
So far I was not able to reproduce the compilation failure -- and I am
asking someone from the PowerPC side to help.
Please apply any minimal #ifdef patch to
sanitizer_platform_limits_linux.cc to make it compile, while keeping
x86_64 tests pass.

If we revert the patch now, I will not be able to work on it again in
nearest months, which means 4.9 will not get updated asan.
How bad that is -- I don't know.

--kcc

On Tue, Nov 12, 2013 at 9:40 AM, Kostya Serebryany <kcc@google.com> wrote:
> So far I was not able to reproduce the compilation failure -- and I am
> asking someone from the PowerPC side to help.
> Please apply any minimal #ifdef patch to sanitizer_platform_limits_linux.cc
> to make it compile, while keeping x86_64 tests pass.
>
> If we revert the patch now, I will not be able to work on it again in
> nearest months, which means 4.9 will not get updated asan.
> How bad that is -- I don't know.
>
> --kcc
>
>
> On Tue, Nov 12, 2013 at 9:37 AM, Michael Meissner
> <meissner@linux.vnet.ibm.com> wrote:
>>
>> It has been a week since the libsanitizer patches were checked in, which
>> broke
>> the PowerPC64 Linux system along with others (PR 59009 for powerpc).
>> Please
>> revert these patches while you are working on proper fixes for all of the
>> hosts
>> and targets.
>>
>> Quoting from the GCC development plan:
>>
>> Patch Reversion
>>
>> If a patch is committed which introduces a regression on any target which
>> the
>> Steering Committee considers to be important and if:
>>
>> the problem is reported to the original poster; 48 hours pass without the
>> original poster or any other party indicating that a fix will be
>> forthcoming in
>> the very near future; two people with write privileges to the affected
>> area of
>> the compiler determine that the best course of action is to revert the
>> patch;
>> then they may revert the patch.
>>
>> (The list of important targets will be revised at the beginning of each
>> release
>> cycle, if necessary, and is part of the release criteria.)
>>
>> After the patch has been reverted, the poster may appeal the decision to
>> the
>> Steering Committee.
>>
>> Note that no distinction is made between patches which are themselves
>> buggy and
>> patches that expose latent bugs elsewhere in the compiler.
>>
>> --
>> Michael Meissner, IBM
>> IBM, M/S 2506R, 550 King Street, Littleton, MA 01460, USA
>> email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797
>>
>
Kostya Serebryany Nov. 12, 2013, 5:43 p.m. UTC | #34
or, alternatively, we can disable libsanitizer on PowerPC if the
PowerPC community does not care enough about it being healthy.

On Tue, Nov 12, 2013 at 9:41 AM, Kostya Serebryany <kcc@google.com> wrote:
> [plain text]
> So far I was not able to reproduce the compilation failure -- and I am
> asking someone from the PowerPC side to help.
> Please apply any minimal #ifdef patch to
> sanitizer_platform_limits_linux.cc to make it compile, while keeping
> x86_64 tests pass.
>
> If we revert the patch now, I will not be able to work on it again in
> nearest months, which means 4.9 will not get updated asan.
> How bad that is -- I don't know.
>
> --kcc
>
> On Tue, Nov 12, 2013 at 9:40 AM, Kostya Serebryany <kcc@google.com> wrote:
>> So far I was not able to reproduce the compilation failure -- and I am
>> asking someone from the PowerPC side to help.
>> Please apply any minimal #ifdef patch to sanitizer_platform_limits_linux.cc
>> to make it compile, while keeping x86_64 tests pass.
>>
>> If we revert the patch now, I will not be able to work on it again in
>> nearest months, which means 4.9 will not get updated asan.
>> How bad that is -- I don't know.
>>
>> --kcc
>>
>>
>> On Tue, Nov 12, 2013 at 9:37 AM, Michael Meissner
>> <meissner@linux.vnet.ibm.com> wrote:
>>>
>>> It has been a week since the libsanitizer patches were checked in, which
>>> broke
>>> the PowerPC64 Linux system along with others (PR 59009 for powerpc).
>>> Please
>>> revert these patches while you are working on proper fixes for all of the
>>> hosts
>>> and targets.
>>>
>>> Quoting from the GCC development plan:
>>>
>>> Patch Reversion
>>>
>>> If a patch is committed which introduces a regression on any target which
>>> the
>>> Steering Committee considers to be important and if:
>>>
>>> the problem is reported to the original poster; 48 hours pass without the
>>> original poster or any other party indicating that a fix will be
>>> forthcoming in
>>> the very near future; two people with write privileges to the affected
>>> area of
>>> the compiler determine that the best course of action is to revert the
>>> patch;
>>> then they may revert the patch.
>>>
>>> (The list of important targets will be revised at the beginning of each
>>> release
>>> cycle, if necessary, and is part of the release criteria.)
>>>
>>> After the patch has been reverted, the poster may appeal the decision to
>>> the
>>> Steering Committee.
>>>
>>> Note that no distinction is made between patches which are themselves
>>> buggy and
>>> patches that expose latent bugs elsewhere in the compiler.
>>>
>>> --
>>> Michael Meissner, IBM
>>> IBM, M/S 2506R, 550 King Street, Littleton, MA 01460, USA
>>> email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797
>>>
>>
Michael Meissner Nov. 12, 2013, 6:04 p.m. UTC | #35
On Tue, Nov 12, 2013 at 09:43:38AM -0800, Kostya Serebryany wrote:
> or, alternatively, we can disable libsanitizer on PowerPC if the
> PowerPC community does not care enough about it being healthy.

I think there should be a global --enable-libsanitizer or whatever option that
would allow people to enable it.  It should only be default on x86_64 until
people are motivated to fix libsantizer on all instances of the platform.
Kostya Serebryany Nov. 12, 2013, 6:07 p.m. UTC | #36
On Tue, Nov 12, 2013 at 10:04 AM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> On Tue, Nov 12, 2013 at 09:43:38AM -0800, Kostya Serebryany wrote:
>> or, alternatively, we can disable libsanitizer on PowerPC if the
>> PowerPC community does not care enough about it being healthy.
>
> I think there should be a global --enable-libsanitizer or whatever option that
> would allow people to enable it.  It should only be default on x86_64 until
> people are motivated to fix libsantizer on all instances of the platform.

I don't mind that.

>
> --
> Michael Meissner, IBM
> IBM, M/S 2506R, 550 King Street, Littleton, MA 01460, USA
> email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797
>
Michael Meissner Nov. 12, 2013, 6:39 p.m. UTC | #37
On Tue, Nov 12, 2013 at 10:07:32AM -0800, Kostya Serebryany wrote:
> On Tue, Nov 12, 2013 at 10:04 AM, Michael Meissner
> <meissner@linux.vnet.ibm.com> wrote:
> > On Tue, Nov 12, 2013 at 09:43:38AM -0800, Kostya Serebryany wrote:
> >> or, alternatively, we can disable libsanitizer on PowerPC if the
> >> PowerPC community does not care enough about it being healthy.
> >
> > I think there should be a global --enable-libsanitizer or whatever option that
> > would allow people to enable it.  It should only be default on x86_64 until
> > people are motivated to fix libsantizer on all instances of the platform.
> 
> I don't mind that.
> 
> >
> > --
> > Michael Meissner, IBM
> > IBM, M/S 2506R, 550 King Street, Littleton, MA 01460, USA
> > email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797
> >

In terms of not being able to reproduce it, I just logged onto the powerpc64
machine on the GCC compile farm (gcc110.fsffrance.org), and I was able to
reproduce the bug in about 15 minutes using no special configure options.

Here is information about the compile farm:
http://gcc.gnu.org/wiki/CompileFarm
Jakub Jelinek Nov. 12, 2013, 6:57 p.m. UTC | #38
On Tue, Nov 12, 2013 at 10:07:32AM -0800, Kostya Serebryany wrote:
> On Tue, Nov 12, 2013 at 10:04 AM, Michael Meissner
> <meissner@linux.vnet.ibm.com> wrote:
> > On Tue, Nov 12, 2013 at 09:43:38AM -0800, Kostya Serebryany wrote:
> >> or, alternatively, we can disable libsanitizer on PowerPC if the
> >> PowerPC community does not care enough about it being healthy.
> >
> > I think there should be a global --enable-libsanitizer or whatever option that
> > would allow people to enable it.  It should only be default on x86_64 until
> > people are motivated to fix libsantizer on all instances of the platform.
> 
> I don't mind that.

Perhaps I'm totally blind, but how exactly are the
sanitizer_common_syscalls.inc interceptors used (seems most of the portability
trouble is caused by that)?  I see it defines tons of functions like
__sanitizer_syscall_post_impl_*
__sanitizer_syscall_pre_impl_*
but I couldn't find anything actually referencing those symbols.  Is that
just dead code for the time being?

	Jakub
Kostya Serebryany Nov. 12, 2013, 6:59 p.m. UTC | #39
On Tue, Nov 12, 2013 at 10:57 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Nov 12, 2013 at 10:07:32AM -0800, Kostya Serebryany wrote:
>> On Tue, Nov 12, 2013 at 10:04 AM, Michael Meissner
>> <meissner@linux.vnet.ibm.com> wrote:
>> > On Tue, Nov 12, 2013 at 09:43:38AM -0800, Kostya Serebryany wrote:
>> >> or, alternatively, we can disable libsanitizer on PowerPC if the
>> >> PowerPC community does not care enough about it being healthy.
>> >
>> > I think there should be a global --enable-libsanitizer or whatever option that
>> > would allow people to enable it.  It should only be default on x86_64 until
>> > people are motivated to fix libsantizer on all instances of the platform.
>>
>> I don't mind that.
>
> Perhaps I'm totally blind, but how exactly are the
> sanitizer_common_syscalls.inc interceptors used (seems most of the portability
> trouble is caused by that)?  I see it defines tons of functions like
> __sanitizer_syscall_post_impl_*
> __sanitizer_syscall_pre_impl_*
> but I couldn't find anything actually referencing those symbols.  Is that
> just dead code for the time being?

This is all dead code in gcc repo. This is why I am asking for any
quick #ifdef.
in clang repo this code is used by MemorySanitizer (and will be used
by asan/tsan later).

>
>         Jakub
Richard Biener Nov. 13, 2013, 10:47 a.m. UTC | #40
On Tue, Nov 12, 2013 at 7:04 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> On Tue, Nov 12, 2013 at 09:43:38AM -0800, Kostya Serebryany wrote:
>> or, alternatively, we can disable libsanitizer on PowerPC if the
>> PowerPC community does not care enough about it being healthy.
>
> I think there should be a global --enable-libsanitizer or whatever option that
> would allow people to enable it.  It should only be default on x86_64 until
> people are motivated to fix libsantizer on all instances of the platform.

You can use --disable-libsanitizer to disable it for now (I'm doing that
on x86_64 as well as it breaks bootstrap on SLE11 as well).

Richard.

> --
> Michael Meissner, IBM
> IBM, M/S 2506R, 550 King Street, Littleton, MA 01460, USA
> email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797
>
diff mbox

Patch

--- gcc/asan.c.jj	2013-10-29 11:58:30.000000000 +0100
+++ gcc/asan.c	2013-10-29 13:04:07.709667677 +0100
@@ -921,6 +921,15 @@  asan_clear_shadow (rtx shadow_mem, HOST_
   add_int_reg_note (jump, REG_BR_PROB, REG_BR_PROB_BASE * 80 / 100);
 }
 
+void
+asan_function_start (void)
+{
+  section *fnsec = function_section (current_function_decl);
+  switch_to_section (fnsec);
+  ASM_OUTPUT_DEBUG_LABEL (asm_out_file, "LASANPC",
+			  current_function_funcdef_no);
+}
+
 /* Insert code to protect stack vars.  The prologue sequence should be emitted
    directly, epilogue sequence returned.  BASE is the register holding the
    stack base, against which OFFSETS array offsets are relative to, OFFSETS
@@ -936,12 +945,13 @@  asan_emit_stack_protection (rtx base, HO
 			    int length)
 {
   rtx shadow_base, shadow_mem, ret, mem;
+  char buf[30];
   unsigned char shadow_bytes[4];
   HOST_WIDE_INT base_offset = offsets[length - 1], offset, prev_offset;
   HOST_WIDE_INT last_offset, last_size;
   int l;
   unsigned char cur_shadow_byte = ASAN_STACK_MAGIC_LEFT;
-  tree str_cst;
+  tree str_cst, decl;
 
   if (shadow_ptr_types[0] == NULL_TREE)
     asan_init_shadow_ptr_types ();
@@ -949,7 +959,6 @@  asan_emit_stack_protection (rtx base, HO
   /* First of all, prepare the description string.  */
   pretty_printer asan_pp;
 
-  pp_string (&asan_pp, "");
   pp_decimal_int (&asan_pp, length / 2 - 1);
   pp_space (&asan_pp);
   for (l = length - 2; l; l -= 2)
@@ -980,7 +989,17 @@  asan_emit_stack_protection (rtx base, HO
   mem = adjust_address (mem, VOIDmode, GET_MODE_SIZE (ptr_mode));
   emit_move_insn (mem, expand_normal (str_cst));
   mem = adjust_address (mem, VOIDmode, GET_MODE_SIZE (ptr_mode));
-  emit_move_insn (mem, expand_normal (str_cst));  // FIXME: should be cur_pc.
+  ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC", current_function_funcdef_no);
+  decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl),
+		     VAR_DECL, get_identifier (buf), char_type_node);
+  TREE_ADDRESSABLE (decl) = 1;
+  TREE_READONLY (decl) = 1;
+  DECL_ARTIFICIAL (decl) = 1;
+  DECL_IGNORED_P (decl) = 1;
+  TREE_STATIC (decl) = 1;
+  TREE_PUBLIC (decl) = 0;
+  TREE_USED (decl) = 1;
+  emit_move_insn (mem, expand_normal (build_fold_addr_expr (decl)));
   shadow_base = expand_binop (Pmode, lshr_optab, base,
 			      GEN_INT (ASAN_SHADOW_SHIFT),
 			      NULL_RTX, 1, OPTAB_DIRECT);
@@ -1979,8 +1998,8 @@  asan_add_global (tree decl, tree type, v
     pp_string (&asan_pp, "<unknown>");
   str_cst = asan_pp_string (&asan_pp);
 
-  pp_string(&module_name_pp, main_input_filename);
-  module_name_cst = asan_pp_string(&module_name_pp);
+  pp_string (&module_name_pp, main_input_filename);
+  module_name_cst = asan_pp_string (&module_name_pp);
 
   if (asan_needs_local_alias (decl))
     {
--- gcc/asan.h.jj	2013-01-11 09:02:50.000000000 +0100
+++ gcc/asan.h	2013-10-29 12:37:54.190798947 +0100
@@ -21,6 +21,7 @@  along with GCC; see the file COPYING3.
 #ifndef TREE_ASAN
 #define TREE_ASAN
 
+extern void asan_function_start (void);
 extern void asan_finish_file (void);
 extern rtx asan_emit_stack_protection (rtx, HOST_WIDE_INT *, tree *, int);
 extern bool asan_protect_global (tree);
--- gcc/final.c.jj	2013-10-23 14:43:12.000000000 +0200
+++ gcc/final.c	2013-10-29 12:49:33.609176613 +0100
@@ -78,6 +78,7 @@  along with GCC; see the file COPYING3.
 #include "cfgloop.h"
 #include "params.h"
 #include "tree-pretty-print.h" /* for dump_function_header */
+#include "asan.h"
 
 #ifdef XCOFF_DEBUGGING_INFO
 #include "xcoffout.h"		/* Needed for external data
@@ -1738,6 +1739,9 @@  final_start_function (rtx first, FILE *f
 
   high_block_linenum = high_function_linenum = last_linenum;
 
+  if (flag_sanitize & SANITIZE_ADDRESS)
+    asan_function_start ();
+
   if (!DECL_IGNORED_P (current_function_decl))
     debug_hooks->begin_prologue (last_linenum, last_filename);