[Bug sanitizer/85924] New: [6 Regression] ASAN: segfault in __interceptor_clock_gettime ( because 'asan_linux.o' for libasan.a built with -DPIC )

jason.vas.dias at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri May 25 12:18:00 GMT 2018


            Bug ID: 85924
           Summary: [6 Regression] ASAN: segfault in
                    __interceptor_clock_gettime ( because 'asan_linux.o'
                    for libasan.a built with -DPIC )
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jason.vas.dias at gmail dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org
  Target Milestone: ---

This is a re-occurence of bug #59063, as tested by 
gcc/testsuite/c-c++-common/asan/pr59063-2.c ,
which fails for builds of gcc-6-branch r260671 .

Problem: on an up-to-date RHEL-7.5 x86_64 system (SL) , where
libtool resolves to /usr/bin/libtool (v2.4.2), after
building in GCC_SRC='.' & running 'make check' :

 $ cd x86_64-linux-gnu  # default $OBJDIR
 $ cd libsanitizer/asan
 $ rm -f asan_linux.o
 $ make  asan_linux.o 2>&1 | tee make_asan_linux.build.log
 /home/devel/OS/gcc-6-branch/host-x86_64-linux-gnu/gcc/xgcc -shared-libgcc
-B/home/devel/OS/gcc-6-branch/host-x86_64-linux-gnu/gcc -nostdinc++
-B/usr/local/x86_64-linux-gnu/bin/ -B/usr/local/x86_64-linux-gnu/lib/ -isystem
/usr/local/x86_64-linux-gnu/include -isystem
/usr/local/x86_64-linux-gnu/sys-include    -D_GNU_SOURCE -D_DEBUG
-D_OBSTACK_SIZE_T="SIZE_T"  -I. -I../../.././libsanitizer/asan -I..  -I
../../.././libsanitizer/include -I ../../.././libsanitizer  -Wall -W
-Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long \
  -fPIC \
# ^^^^^    OUCH! causes infinite recursion and core dump in 
#          __interception::sigaction
-no-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables
-fvisibility=hidden -Wno-variadic-macros -fno-ipa-icf
-I../../libstdc++-v3/include     -I../../libstdc++-v3/include/x86_64-linux-gnu 
   -I../../.././libsanitizer/../libstdc++-v3/libsupc++ -std=gnu++11 -g -O2
-D_GNU_SOURCE -MT asan_linux.o -MD -MP -MF .deps/asan_linux.Tpo -c -o
asan_linux.o ../../.././libsanitizer/asan/asan_linux.cc
mv -f .deps/asan_linux.Tpo .deps/asan_linux.Po

(Same happens for './asan_rtl.o') .

For some reason, for only the gcc-6-branch (NOT the gcc-{4,5,7}-branches,
libtool 2.4.2 is appending '-fPIC' to the compile options for 
( which is meant ONLY to be included in the static .libs/libasan.a ;
  .libs/asan_linux.o is always correctly compiled with '-fPIC -DPIC' ,
  and is destined for inclusion in .libs/libasan.so.*
Unfortunately, setting -fPIC does make 'PIC' defined() .
So the __asan_init method thinks it is in a SHARED LIBRARY,
and invokes :
but since the default load module now interposes its
    '__interception::sigaction' ,
(which is called by REAL(sigaction)) ,
     __interception::sigaction , which dereferences that
dlsym return value, calls itself in an infinite loop until
the process runs out of stack and coredumps .

I cannot understand why the build scripts or libtool should be appending -fPIC 
here - they do not in gcc-{4,5,7}-branches .

More information about the Gcc-bugs mailing list