Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Don't override operator new if GDB is built with -fsanitize=address
Date: Tue, 25 Oct 2016 09:39:00 -0000	[thread overview]
Message-ID: <6afd5d0c-5e8e-1edb-5fa7-cd7c80d493df@redhat.com> (raw)
In-Reply-To: <1477387295-24846-1-git-send-email-yao.qi@linaro.org>

On 10/25/2016 10:21 AM, Yao Qi wrote:
> Nowadays, if we build GDB with -fsanitize=address, we can get the asan
> error below,
> 
> (gdb) quit
> =================================================================
> ==9723==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x60200003bf70
>     #0 0x7f88f3837527 in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x55527)
>     #1 0xac8e13 in __gnu_cxx::new_allocator<void (*)()>::deallocate(void (**)(), unsigned long) /usr/include/c++/4.9/ext/new_allocator.h:110
>     #2 0xac8cc2 in __gnu_cxx::__alloc_traits<std::allocator<void (*)()> >::deallocate(std::allocator<void (*)()>&, void (**)(), unsigned long) /usr/include/c++/4.9/ext/alloc_traits.h:185
> ....
> 0x60200003bf70 is located 0 bytes inside of 8-byte region [0x60200003bf70,0x60200003bf78)
> allocated by thread T0 here:
>     #0 0x7f88f38367ef in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x547ef)
>     #1 0xbd2762 in operator new(unsigned long) /home/yao/SourceCode/gnu/gdb/git/gdb/common/new-op.c:42
>     #2 0xac8edc in __gnu_cxx::new_allocator<void (*)()>::allocate(unsigned long, void const*) /usr/include/c++/4.9/ext/new_allocator.h:104
>     #3 0xac8d81 in __gnu_cxx::__alloc_traits<std::allocator<void (*)()> >::allocate(std::allocator<void (*)()>&, unsigned long) /usr/include/c++/4.9/ext/alloc_traits.h:182
> 
> The reason for this is that we override operator new but don't override
> operator delete.  This patch does the override only if the code is NOT
> compiled with asan.
> 
> gdb:
> 
> 2016-10-25  Yao Qi  <yao.qi@linaro.org>
> 
> 	PR gdb/20716
> 	* common/new-op.c (__has_feature): New macro.
> 	Don't override operator new if asan is used.

LGTM.

Thanks,
Pedro Alves


  reply	other threads:[~2016-10-25  9:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25  9:21 Yao Qi
2016-10-25  9:39 ` Pedro Alves [this message]
     [not found]   ` <CAH=s-POJSmo1rm2JaxmSG7GwqYqRxgv0tMYJKYcix8ddcvctFw@mail.gmail.com>
2016-10-25 10:38     ` Pedro Alves
2016-10-25 10:40       ` Pedro Alves
2016-10-25 11:39         ` Yao Qi
2016-10-25 12:33           ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6afd5d0c-5e8e-1edb-5fa7-cd7c80d493df@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox