From patchwork Tue Oct 25 10:40:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 16789 Received: (qmail 23677 invoked by alias); 25 Oct 2016 10:40:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 23658 invoked by uid 89); 25 Oct 2016 10:40:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Thunderbird, thunderbird, Our, our X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Oct 2016 10:40:25 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B62ED80F94; Tue, 25 Oct 2016 10:40:24 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9PAeNEf003721; Tue, 25 Oct 2016 06:40:24 -0400 Subject: Re: [PATCH] Don't override operator new if GDB is built with -fsanitize=address To: Yao Qi , GDB Patches References: <1477387295-24846-1-git-send-email-yao.qi@linaro.org> <6afd5d0c-5e8e-1edb-5fa7-cd7c80d493df@redhat.com> <8800a3ba-856f-dbc2-c350-ae06309d38ba@redhat.com> From: Pedro Alves Message-ID: <49110e6f-e2e0-e5ab-75cf-04a29654fa5f@redhat.com> Date: Tue, 25 Oct 2016 11:40:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <8800a3ba-856f-dbc2-c350-ae06309d38ba@redhat.com> 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 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 * common/new-op.c: Add comment about -fsanitize=address. --- gdb/common/new-op.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdb/common/new-op.c b/gdb/common/new-op.c index f04c5cb..1eb4f94 100644 --- a/gdb/common/new-op.c +++ 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 + 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