When I run any of the LTO wrappers (gcc-ar, gcc-nm, gcc-ranlib) with absolute path (e.g. /usr/bin/gcc-ar), the program segfaults immediately. I tried to run some debugging, and I found the culprit is in line 197-204 of gcc-ar.c. Basically gcc-ar was trying to find ar, and "/usr/bin/" was removed from the list of path to search for ar in line 203 of gcc-ar.c. As a result ar cannot be found and the program segfaults. I'm using Arch Linux and my gcc version info is as follows: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /home/hao/code/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,lto --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 7.1.1 20170508 (GCC)
It seems to work for me: > /usr/bin/gcc-ar-7 t t.a t.o any specific command-line to try? I suppose for me it finds ar with the first /* Find the wrapped binutils program. */ exe_name = find_a_file (&target_path, PERSONALITY, X_OK); if (!exe_name) {
Thank you for your reply. For me basically any arguments with /usr/bin/gcc-ar fails with segfault, even running /usr/bin/gcc-ar with no additional arguments at all. When I run gcc-ar with gdb (here I don't even need to have the absolute path, "gdb gcc-ar" fails with segfault), before line 203 of gcc-ar.c, the variable path.plist consists of the following entries: {0x6070a0 "/usr/local/sbin/", 0x607010 "/usr/local/bin/", 0x6073c0 "/usr/bin/", 0x607400 "/usr/lib/jvm/default/bin/", 0x607450 "/usr/bin/site_perl/", 0x607490 "/usr/bin/vendor_perl/", 0x6074d0 "/usr/bin/core_perl/"} After line 203, /usr/bin/ is removed from the list of paths: {0x6070a0 "/usr/local/sbin/", 0x607010 "/usr/local/bin/", 0x0 , 0x607400 "/usr/lib/jvm/default/bin/", 0x607450 "/usr/bin/site_perl/", 0x607490 "/usr/bin/vendor_perl/", 0x6074d0 "/usr/bin/core_perl/"} Since the third item is set to 0, strcpy segfaults at file-find.c:81.
Hi, any progress with fixing this issue? Arch users found that 'arduino' tool crashes because of this bug. https://bugs.archlinux.org/task/54159
Problematic change has been reverted in r253886 and backported to gcc-7-branch. (We also did that downstream in Arch Linux prior the revert.)
Even though PR 81829 is newer, it is what is recorded as the bug report in the changelog so closing this one as a dup of bug 81829. *** This bug has been marked as a duplicate of bug 81829 ***