From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6785 invoked by alias); 13 Oct 2014 11:47:19 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 6761 invoked by uid 48); 13 Oct 2014 11:47:15 -0000 From: "i.palachev at samsung dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/61048] compiling with -fsanitize=address crashes GCC if pointers are used Date: Mon, 13 Oct 2014 11:47:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i.palachev at samsung dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-10/txt/msg00934.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61048 Ilya Palachev changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |i.palachev at samsung dot com --- Comment #1 from Ilya Palachev --- The error happens for the following sequence of commands g++ test.cpp -c -o test.o -fsanitize=address -flto g++ test.o -o test -Wl,-flto And does not happen for the following sequence of commands: g++ test.cpp -c -o test.o -fsanitize=address -flto g++ test.o -o test -Wl,-flto -fsanitize=address The ICE happens because sanitizer builtins are not initialized (returned tree is null). I've tried to force their initialization as follows: diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index bc53632..f5ca849 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-inline.h" #include "params.h" #include "ipa-utils.h" +#include "asan.h" /* Number of parallel tasks to run, -1 if we want to use GNU Make jobserver. */ @@ -1856,6 +1857,9 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, data_in = lto_data_in_create (decl_data, (const char *) data + string_offset, header->string_size, resolutions); + /* Initialize sanitizer builtins if necessary. */ + initialize_sanitizer_builtins(); + /* We do not uniquify the pre-loaded cache entries, those are middle-end internal types that should not be merged. */ But after applying this patch the following error happens during the 2nd command: g++ test.o -o test -Wl,-flto /tmp/ccEhycoY.ltrans0.ltrans.o:ccEhycoY.ltrans0.o:function __static_initialization_and_destruction_0(int, int): error: undefined reference to '__asan_before_dynamic_init' /tmp/ccEhycoY.ltrans0.ltrans.o:ccEhycoY.ltrans0.o:function __static_initialization_and_destruction_0(int, int): error: undefined reference to '__asan_after_dynamic_init' collect2: error: ld returned 1 exit status