Bug 23646 - gold segfault when using --threads
Summary: gold segfault when using --threads
Status: WAITING
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-13 08:38 UTC by Jean-Michaël Celerier
Modified: 2019-02-20 16:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2019-02-20 00:00:00


Attachments
source file which exhibits the problem (626.64 KB, text/x-c++src)
2018-09-13 08:38 UTC, Jean-Michaël Celerier
Details
better source file (227.67 KB, text/x-c++src)
2018-09-13 08:56 UTC, Jean-Michaël Celerier
Details
Requested recordings (16.24 KB, application/gzip)
2019-02-20 16:39 UTC, Jean-Michaël Celerier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Michaël Celerier 2018-09-13 08:38:14 UTC
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.
Comment 1 Jean-Michaël Celerier 2018-09-13 08:56:13 UTC
Created attachment 11240 [details]
better source file
Comment 2 Jean-Michaël Celerier 2018-09-13 08:57:06 UTC
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); }
Comment 3 Jean-Michaël Celerier 2018-09-13 09:18:57 UTC
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)
Comment 4 Cary Coutant 2018-10-24 01:30:45 UTC
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?
Comment 5 Jean-Michaël Celerier 2019-02-20 08:16:33 UTC
Still crashes for me with the same binutils version. It works without LTO. I use g++ 8.2.1
Comment 6 Cary Coutant 2019-02-20 16:09:42 UTC
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.
Comment 7 Jean-Michaël Celerier 2019-02-20 16:39:27 UTC
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)