Created attachment 11239 [details] source file which exhibits the problem Repro in attachment. Using "GNU gold (GNU Binutils 2.31.1) 1.16". Build with $ g++ -flto -std=gnu++17 precompiled.cpp -shared -fuse-ld=gold -Wl,--threads -Wl,--thread-count,16 to get a ld segfault.
Created attachment 11240 [details] better source file
I added a source file where I removed all the code until I didn't get the segfault anymore. The culprit (code-wise) is the last line (line 67158): template <typename T> T handle::cast() const { return pybind11::cast<T>(*this); }
also, if it can be useful : gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/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++,ada,fortran,go,lto,objc,obj-c++ --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 --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp --enable-cet=auto Thread model: posix gcc version 8.2.1 20180831 (GCC)
Sorry, I can't reproduce the crash. I had to add -fpic to the compile command in order to link without errors. Either way, gold did not segfault. I've tried with various values for --thread-count. Can you reproduce without LTO? Can you get a stack trace from the point of the segfault?
Still crashes for me with the same binutils version. It works without LTO. I use g++ 8.2.1
Can I trouble you to add -Wl,--debug=plugin and upload a tar of the resulting directory? You may need to run that without threads to get complete debug output, but that may help me reproduce it here.
Created attachment 11634 [details] Requested recordings Here are the recordings, I did one without threads (which does not crash) and one with 2 threads (which crashes)