[Bug lto/61048] compiling with -fsanitize=address crashes GCC if pointers are used
i.palachev at samsung dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 13 11:47:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61048
Ilya Palachev <i.palachev at samsung dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |i.palachev at samsung dot com
--- Comment #1 from Ilya Palachev <i.palachev at samsung dot com> ---
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
More information about the Gcc-bugs
mailing list