From patchwork Thu Nov 14 14:24:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jack Howarth X-Patchwork-Id: 291241 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 74F2A2C009D for ; Fri, 15 Nov 2013 01:24:29 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=WwB1FOFUKrgRiMqClqoA7gGKJVk/LydT2l4VkLIpQ2Nhp/WzMP 9io7iV8GHIUIvEAlGX8O8/t9u5ZP+krebYo54hjk7csr62Zx2nKrymFfGHYA+cDA HUKWUbT5XE7T9yfCqmwX70siMpo5FgIg6Bre59rnTJiPJ+We6sZERLYg0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=pWgxTze3rJm/dSMF4aK5Q9klPnk=; b=c6ZvchYk/Zlpy56wXXBM 8fW/5Kuw423LC0RRstp4veuCuzyl+uNUmG+wanGIPa+NW7hLENfcF0AKsZma9Ze9 du0V3ULZgW1cch3nAZ8vUSvkcN8rYsl4eNTS8pMbYo9mZpMQ9NS8TNEN975px7/n b3CtnMvFtxiv9Jss9rAZ1S0= Received: (qmail 12897 invoked by alias); 14 Nov 2013 14:24:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 12880 invoked by uid 89); 14 Nov 2013 14:24:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: bromo.med.uc.edu Received: from Unknown (HELO bromo.med.uc.edu) (129.137.3.146) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Nov 2013 14:24:13 +0000 Received: from bromo.med.uc.edu (localhost.localdomain [127.0.0.1]) by bromo.med.uc.edu (Postfix) with ESMTP id 4A8C0B0045; Thu, 14 Nov 2013 09:24:05 -0500 (EST) Received: (from howarth@localhost) by bromo.med.uc.edu (8.14.3/8.14.3/Submit) id rAEEO43c013114; Thu, 14 Nov 2013 09:24:04 -0500 Date: Thu, 14 Nov 2013 09:24:04 -0500 From: Jack Howarth To: gcc-patches@gcc.gnu.org Cc: kcc@google.com, glider@google.com, mikestump@comcast.net, jakub@redhat.com, dodji@redhat.com, dvyukov@google.com, iain@codesourcery.com Subject: [PATCH]: backport fix for PR sanitizer/58994 Message-ID: <20131114142404.GA13112@bromo.med.uc.edu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) The attached patch backports http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20131111/194748.html to gcc trunk and eliminates the asan.exp failures at -m64 on darwin. Bootstrap and regression tested on x86_64-apple-darwin12 and x86_64-apple-darwin13. Jack ps Kostya, can you handled the commit? Thanks in advance. 2013-11-14 Kostya Serebryany Jack Howarth libsanitizer/ PR sanitizer/58994 Backport from upstream revision 194573 * asan/asan_interceptors.cc (COMMON_INTERCEPTOR_ENTER): Fall back to the original functions in the common libsanitizer interceptors and the __cxa_atexit() interceptor on Darwin. 2013-11-14 Kostya Serebryany Jack Howarth libsanitizer/ PR sanitizer/58994 Backport from upstream revision 194573 * asan/asan_interceptors.cc (COMMON_INTERCEPTOR_ENTER): Fall back to the original functions in the common libsanitizer interceptors and the __cxa_atexit() interceptor on Darwin. Index: libsanitizer/asan/asan_interceptors.cc =================================================================== --- libsanitizer/asan/asan_interceptors.cc (revision 204753) +++ libsanitizer/asan/asan_interceptors.cc (working copy) @@ -106,12 +106,13 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, #define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size) \ ASAN_WRITE_RANGE(ptr, size) #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) ASAN_READ_RANGE(ptr, size) -#define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \ - do { \ - if (asan_init_is_running) return REAL(func)(__VA_ARGS__); \ - ctx = 0; \ - (void) ctx; \ - ENSURE_ASAN_INITED(); \ +#define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \ + do { \ + if (asan_init_is_running) return REAL(func)(__VA_ARGS__); \ + ctx = 0; \ + (void) ctx; \ + if (SANITIZER_MAC && !asan_inited) return REAL(func)(__VA_ARGS__); \ + ENSURE_ASAN_INITED(); \ } while (false) #define COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd) \ do { \ @@ -634,6 +635,9 @@ static void AtCxaAtexit(void *unused) { #if ASAN_INTERCEPT___CXA_ATEXIT INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg, void *dso_handle) { +#if SANITIZER_MAC + if (!asan_inited) return REAL(__cxa_atexit)(func, arg, dso_handle); +#endif ENSURE_ASAN_INITED(); int res = REAL(__cxa_atexit)(func, arg, dso_handle); REAL(__cxa_atexit)(AtCxaAtexit, 0, 0); Index: libsanitizer/asan/asan_interceptors.cc =================================================================== --- libsanitizer/asan/asan_interceptors.cc (revision 204753) +++ libsanitizer/asan/asan_interceptors.cc (working copy) @@ -106,12 +106,13 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, #define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size) \ ASAN_WRITE_RANGE(ptr, size) #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) ASAN_READ_RANGE(ptr, size) -#define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \ - do { \ - if (asan_init_is_running) return REAL(func)(__VA_ARGS__); \ - ctx = 0; \ - (void) ctx; \ - ENSURE_ASAN_INITED(); \ +#define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \ + do { \ + if (asan_init_is_running) return REAL(func)(__VA_ARGS__); \ + ctx = 0; \ + (void) ctx; \ + if (SANITIZER_MAC && !asan_inited) return REAL(func)(__VA_ARGS__); \ + ENSURE_ASAN_INITED(); \ } while (false) #define COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd) \ do { \ @@ -634,6 +635,9 @@ static void AtCxaAtexit(void *unused) { #if ASAN_INTERCEPT___CXA_ATEXIT INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg, void *dso_handle) { +#if SANITIZER_MAC + if (!asan_inited) return REAL(__cxa_atexit)(func, arg, dso_handle); +#endif ENSURE_ASAN_INITED(); int res = REAL(__cxa_atexit)(func, arg, dso_handle); REAL(__cxa_atexit)(AtCxaAtexit, 0, 0);