Don't override operator new if GDB is built with -fsanitize=address
Commit Message
On 10/25/2016 11:38 AM, Pedro Alves wrote:
> How about this follow up?
On 10/25/2016 11:38 AM, Pedro Alves wrote:
> +++ b/gdb/common/new-op.c
> @@ -33,6 +33,12 @@
> new-handler function instead (std::set_new_handler) because we want
> to catch allocation errors from within global constructors too.
> + Skip overriding if building with -fsanitize=address though.
> + Address sanitizer wants to override operator new/delete too in
Bah, looks like "edit as new" with Thunderbird messed
up the patch... Here it is again...
From e58eb16a5f27b1ee39c45642a80da7364763a07b Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 25 Oct 2016 11:20:03 +0100
Subject: [PATCH] new-op.c: Add comment about -fsanitize=address
gdb/ChangeLog:
2016-10-25 Pedro Alves <palves@redhat.com>
* common/new-op.c: Add comment about -fsanitize=address.
---
gdb/common/new-op.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Tue, Oct 25, 2016 at 11:40 AM, Pedro Alves <palves@redhat.com> wrote:
>
> gdb/ChangeLog:
> 2016-10-25 Pedro Alves <palves@redhat.com>
>
> * common/new-op.c: Add comment about -fsanitize=address.
Patch is good to me.
On 10/25/2016 12:39 PM, Yao Qi wrote:
> On Tue, Oct 25, 2016 at 11:40 AM, Pedro Alves <palves@redhat.com> wrote:
>>
>> gdb/ChangeLog:
>> 2016-10-25 Pedro Alves <palves@redhat.com>
>>
>> * common/new-op.c: Add comment about -fsanitize=address.
>
> Patch is good to me.
>
Pushed.
Thanks,
Pedro Alves
@@ -33,6 +33,12 @@
new-handler function instead (std::set_new_handler) because we want
to catch allocation errors from within global constructors too.
+ Skip overriding if building with -fsanitize=address though.
+ Address sanitizer wants to override operator new/delete too in
+ order to detect malloc+delete and new+free mismatches. Our
+ versions would mask out ASan's, with the result of losing that
+ useful mismatch detection.
+
Note that C++ implementations could either have their throw
versions call the nothrow versions (libstdc++), or the other way
around (clang/libc++). For that reason, we replace both throw and