--disable-bootstrap --enable-checking=valgrind doesn't build: ... true "AR_FLAGS=rc" "CC_FOR_BUILD=gcc" "CFLAGS=-g -O2" "CXXFLAGS=-g -O2 -D_GNU_SOURCE" "CFLAGS_FOR_BUILD=-g -O2" "CFLAGS_FOR_TARGET=-g -O2" "INSTALL=/ usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c -m 644" "INSTALL_PROGRAM=/usr/bin/install -c" "INSTALL_SCRIPT=/usr/bin/install -c" "JC1FLAGS=" "LDFLAGS=" "LIBCFLAGS=-g -O2" "LIBCFLAGS_FOR_TARGET=-g -O2" "MAKE=make" "MAKEINFO=makeinfo --split-size=5000000 --split-size=5000000 " "PICFLAG=" "P ICFLAG_FOR_TARGET=" "SHELL=/bin/sh" "RUNTESTFLAGS=" "exec_prefix=/usr/local" "infodir=/usr/local/share/info" "libdir=/usr/local/lib" "prefix=/usr/loc al" "includedir=/usr/local/include" "AR=ar" "AS=/var/tmp/gcc_build_dir/./gcc/as" "CC=/var/tmp/gcc_build_dir/./gcc/xgcc -B/var/tmp/gcc_build_dir/./gcc / -B/usr/local/x86_64-unknown-linux-gnu/bin/ -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/x86_64-unknown-linux-gnu/include -isystem /usr/local/x86_64-unknown-linux-gnu/sys-include " "CXX=-B/usr/local/x86_64-unknown-linux-gnu/bin/ -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isys tem /usr/local/x86_64-unknown-linux-gnu/include -isystem /usr/local/x86_64-unknown-linux-gnu/sys-include " "LD=/var/tmp/gcc_build_dir/./gcc/collect -ld" "LIBCFLAGS=-g -O2" "NM=/var/tmp/gcc_build_dir/./gcc/nm" "PICFLAG=" "RANLIB=ranlib" "DESTDIR=" DO=all multi-do # make /bin/sh ./libtool --tag=CC --mode=link /var/tmp/gcc_build_dir/./gcc/xgcc -B/var/tmp/gcc_build_dir/./gcc/ -B/usr/local/x86_64-unknown-linux-gnu/bin/ -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/x86_64-unknown-linux-gnu/include -isystem /usr/local/x86_64-unknown-linux-gnu/sys-inc lude -Wall -g -O2 -version-info `grep -v '^#' /home/markus/gcc/libssp/libtool-version` -Wl,--version-script=/home/markus/gcc/libssp/ssp.map -o l ibssp.la -rpath /usr/local/lib/../lib64 ssp.lo gets-chk.lo memcpy-chk.lo memmove-chk.lo mempcpy-chk.lo memset-chk.lo snprintf-chk.lo sprintf-chk.lo s tpcpy-chk.lo strcat-chk.lo strcpy-chk.lo strncat-chk.lo strncpy-chk.lo vsnprintf-chk.lo vsprintf-chk.lo libtool: link: /var/tmp/gcc_build_dir/./gcc/xgcc -B/var/tmp/gcc_build_dir/./gcc/ -B/usr/local/x86_64-unknown-linux-gnu/bin/ -B/usr/local/x86_64-unkno wn-linux-gnu/lib/ -isystem /usr/local/x86_64-unknown-linux-gnu/include -isystem /usr/local/x86_64-unknown-linux-gnu/sys-include -shared .libs/ssp .o .libs/gets-chk.o .libs/memcpy-chk.o .libs/memmove-chk.o .libs/mempcpy-chk.o .libs/memset-chk.o .libs/snprintf-chk.o .libs/sprintf-chk.o .libs/stpc py-chk.o .libs/strcat-chk.o .libs/strcpy-chk.o .libs/strncat-chk.o .libs/strncpy-chk.o .libs/vsnprintf-chk.o .libs/vsprintf-chk.o -O2 -Wl,--versi on-script=/home/markus/gcc/libssp/ssp.map -Wl,-soname -Wl,libssp.so.0 -o .libs/libssp.so.0.0.0 /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/ssp.o: requires dynamic R_X86_64_32 reloc which may overf low at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/ssp.o: requires dynamic R_X86_64_PC32 reloc against '__st ack_chk_guard' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/gets-chk.o: requires dynamic R_X86_64_PC32 reloc against 'malloc' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/memcpy-chk.o: requires dynamic R_X86_64_PC32 reloc agains t '__chk_fail' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/memmove-chk.o: requires dynamic R_X86_64_PC32 reloc again st '__chk_fail' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/mempcpy-chk.o: requires dynamic R_X86_64_PC32 reloc again st 'memcpy' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/memset-chk.o: requires dynamic R_X86_64_PC32 reloc agains t '__chk_fail' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/snprintf-chk.o: requires dynamic R_X86_64_PC32 reloc agai nst 'vsnprintf' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/sprintf-chk.o: requires dynamic R_X86_64_PC32 reloc again st 'vsnprintf' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/stpcpy-chk.o: requires dynamic R_X86_64_PC32 reloc agains t 'strlen' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/strcat-chk.o: requires dynamic R_X86_64_PC32 reloc agains t '__chk_fail' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/strcpy-chk.o: requires dynamic R_X86_64_PC32 reloc agains t 'strlen' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/strncat-chk.o: requires dynamic R_X86_64_PC32 reloc again st '__chk_fail' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/strncpy-chk.o: requires dynamic R_X86_64_PC32 reloc again st '__chk_fail' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/vsnprintf-chk.o: requires dynamic R_X86_64_PC32 reloc aga inst '__chk_fail' which may overflow at runtime; recompile with -fPIC /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: .libs/vsprintf-chk.o: requires dynamic R_X86_64_PC32 reloc agai nst 'vsnprintf' which may overflow at runtime; recompile with -fPIC collect2: error: ld returned 1 exit status make[3]: *** [libssp.la] Error 1
At x86_64-unknown-linux-gnu, the build fails at a different place: ... libtool: link: /home/smatz/build-191654-lto-checking-valgrind-disable-bootstrap-disable-graphite/./gcc/xgcc -B/home/smatz/build-191654-lto-checking-valgrind-disable-bootstrap-disable-graphite/./gcc/ -B/mnt/svn/gcc-trunk/binary-191654-lto-checking-valgrind-disable-bootstrap-disable-graphite/x86_64-unknown-linux-gnu/bin/ -B/mnt/svn/gcc-trunk/binary-191654-lto-checking-valgrind-disable-bootstrap-disable-graphite/x86_64-unknown-linux-gnu/lib/ -isystem /mnt/svn/gcc-trunk/binary-191654-lto-checking-valgrind-disable-bootstrap-disable-graphite/x86_64-unknown-linux-gnu/include -isystem /mnt/svn/gcc-trunk/binary-191654-lto-checking-valgrind-disable-bootstrap-disable-graphite/x86_64-unknown-linux-gnu/sys-include -shared math/.libs/acoshq.o math/.libs/fmodq.o math/.libs/acosq.o math/.libs/frexpq.o math/.libs/rem_pio2q.o math/.libs/asinhq.o math/.libs/hypotq.o math/.libs/remainderq.o math/.libs/asinq.o math/.libs/rintq.o math/.libs/atan2q.o math/.libs/isinfq.o math/.libs/roundq.o math/.libs/atanhq.o math/.libs/isnanq.o math/.libs/scalblnq.o math/.libs/atanq.o math/.libs/j0q.o math/.libs/scalbnq.o math/.libs/cbrtq.o math/.libs/j1q.o math/.libs/signbitq.o math/.libs/ceilq.o math/.libs/jnq.o math/.libs/sincos_table.o math/.libs/complex.o math/.libs/ldexpq.o math/.libs/sincosq.o math/.libs/copysignq.o math/.libs/lgammaq.o math/.libs/sincosq_kernel.o math/.libs/coshq.o math/.libs/llroundq.o math/.libs/sinhq.o math/.libs/cosq.o math/.libs/log10q.o math/.libs/sinq.o math/.libs/cosq_kernel.o math/.libs/log1pq.o math/.libs/sinq_kernel.o math/.libs/erfq.o math/.libs/logq.o math/.libs/sqrtq.o math/.libs/expm1q.o math/.libs/lroundq.o math/.libs/tanhq.o math/.libs/expq.o math/.libs/modfq.o math/.libs/tanq.o math/.libs/fabsq.o math/.libs/nanq.o math/.libs/tgammaq.o math/.libs/finiteq.o math/.libs/nextafterq.o math/.libs/truncq.o math/.libs/floorq.o math/.libs/powq.o math/.libs/fmaq.o math/.libs/cacoshq.o math/.libs/cacosq.o math/.libs/casinhq.o math/.libs/casinq.o math/.libs/catanhq.o math/.libs/catanq.o math/.libs/cimagq.o math/.libs/conjq.o math/.libs/cprojq.o math/.libs/crealq.o math/.libs/fdimq.o math/.libs/fmaxq.o math/.libs/fminq.o math/.libs/ilogbq.o math/.libs/llrintq.o math/.libs/log2q.o math/.libs/lrintq.o math/.libs/nearbyintq.o math/.libs/remquoq.o printf/.libs/addmul_1.o printf/.libs/add_n.o printf/.libs/cmp.o printf/.libs/divrem.o printf/.libs/flt1282mpn.o printf/.libs/fpioconst.o printf/.libs/lshift.o printf/.libs/mul_1.o printf/.libs/mul_n.o printf/.libs/mul.o printf/.libs/printf_fphex.o printf/.libs/printf_fp.o printf/.libs/quadmath-printf.o printf/.libs/rshift.o printf/.libs/submul_1.o printf/.libs/sub_n.o strtod/.libs/strtoflt128.o strtod/.libs/mpn2flt128.o strtod/.libs/tens_in_limb.o -lm -Wl,--version-script=/mnt/svn/gcc-trunk/libquadmath/quadmath.map -Wl,-soname -Wl,libquadmath.so.0 -o .libs/libquadmath.so.0.0.0 /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../x86_64-pc-linux-gnu/bin/ld: math/.libs/fmodq.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC math/.libs/fmodq.o: could not read symbols: Bad value collect2: error: ld returned 1 exit status make[3]: *** [libquadmath.la] Error 1 make[3]: Leaving directory `/home/smatz/build-191654-lto-checking-valgrind-disable-bootstrap-disable-graphite/x86_64-unknown-linux-gnu/libquadmath' make[2]: *** [all] Error 2 make[2]: Leaving directory `/home/smatz/build-191654-lto-checking-valgrind-disable-bootstrap-disable-graphite/x86_64-unknown-linux-gnu/libquadmath' make[1]: *** [all-target-libquadmath] Error 2 make[1]: Leaving directory `/home/smatz/build-191654-lto-checking-valgrind-disable-bootstrap-disable-graphite' make: *** [all] Error 2
Please try ld.bfd from binutils trunk or 2.23.
PIC detection failed with valgrind: configure:8446: /export/build/gnu/gcc-lto-valgrind/build-x86_64-linux/./gcc/xgcc -B/export/build/gnu/gcc-lto-valgrind/build-x86_64-linux/./gcc/ -B/usr/local/x86_64-unknown-linux-gnu/bin/ -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/x86_64-unknown-linux-gnu/include -isystem /usr/local/x86_64-unknown-linux-gnu/sys-include -m32 -c -g -O2 -pthread -fPIC -DPIC -DPIC conftest.c >&5 ==15652== Invalid read of size 8 ==15652== at 0xEF7C94: search_line_sse42(unsigned char const*, unsigned char const*) (lex.c:464) ==15652== by 0xEF7F48: _cpp_clean_line (lex.c:742)
Please try git hjl/valgrind branch: http://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/heads/hjl/valgrind
Maybe VALGRIND_DISCARD would come handy here?
(In reply to comment #4) > Please try git hjl/valgrind branch: > > http://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/heads/hjl/valgrind It builds fine now. Thank you.
Created attachment 28445 [details] Prototype patch that introduces VALGRIND_MAKE_MEM_DEFINED Attached prototype patch builds on HJ's patch. The patch detects valgrind in the same way as in gcc directory (actually, it just copies relevant bits) and changes: + memset (to.text + to.len + 1, 0, 16); to + VALGRIND_DISCARD (VALGRIND_MAKE_MEM_DEFINED (to.text + to.len + 1, 16)); (BTW: Probably, we should align end of buffer to 16 byte boundary instead of hardcoding 16.) (BTW2: the test in the following code in the patch is obviously wrong: +if test $enable_checking != no ; then + # It is certainly possible that there's valgrind but no valgrind.h. + # GCC relies on making annotations so we must have both. + AC_MSG_CHECKING(for VALGRIND_DISCARD in <valgrind/memcheck.h>) + AC_PREPROC_IFELSE([AC_LANG_SOURCE( ...)
(In reply to comment #7) > Created attachment 28445 [details] > Prototype patch that introduces VALGRIND_MAKE_MEM_DEFINED > > Attached prototype patch builds on HJ's patch. The patch detects valgrind in > the same way as in gcc directory (actually, it just copies relevant bits) and > changes: > > + memset (to.text + to.len + 1, 0, 16); > > to > > + VALGRIND_DISCARD (VALGRIND_MAKE_MEM_DEFINED (to.text + to.len + 1, 16)); > > (BTW: Probably, we should align end of buffer to 16 byte boundary instead of > hardcoding 16.) > libcpp will read in advance beyond the end of buffer in some cases, even without SSE optimization.
(In reply to comment #8) > libcpp will read in advance beyond the end of buffer in > some cases, even without SSE optimization. I'd call this a bug.
(In reply to comment #9) > (In reply to comment #8) > > > libcpp will read in advance beyond the end of buffer in > > some cases, even without SSE optimization. > > I'd call this a bug. No it is not a bug. Even if the read happens, since a null character is found, the behavior does not change. Also it is never on an unaligned read so we can never hit a page fault due to unmapped pages.
search_line_acc_char has /* Align the buffer. Mask out any bytes from before the beginning. */ p = (word_type *)((uintptr_t)s & -sizeof(word_type)); It is OK to pad the buffer end just to 16-byte aligned.
This patch: http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01973.html works.
Author: jakub Date: Mon Dec 3 17:19:47 2012 New Revision: 194102 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194102 Log: PR bootstrap/55380 PR other/54691 * files.c (read_file_guts): Allocate extra 16 bytes instead of 1 byte at the end of buf. Pass size + 16 instead of size to _cpp_convert_input. * charset.c (_cpp_convert_input): Reallocate if there aren't at least 16 bytes beyond to.len in the buffer. Clear 16 bytes at to.text + to.len. Modified: trunk/libcpp/ChangeLog trunk/libcpp/charset.c trunk/libcpp/files.c
Should be fixed now.