https://bugs.llvm.org/show_bug.cgi?id=41508

            Bug ID: 41508
           Summary: race condition deadlock in wasm linker
           Product: lld
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedb...@nondot.org
          Reporter: and...@ziglang.org
                CC: llvm-bugs@lists.llvm.org, peter.sm...@linaro.org

Created attachment 21775
  --> https://bugs.llvm.org/attachment.cgi?id=21775&action=edit
test.o

Tested against LLD 8.0.0.


Frontend code:

export fn cwa_main() i32 {
    force_crash() catch unreachable;

    return 0;
}

extern fn random_i32() i32;
const ErrorStuff = error{
    Stuff,
};

fn force_crash() !void {
    if (@mod(random_i32(), 2) == 1) {
        return error.Stuff;
    }
}


Command to build:

zig build-exe test.zig -target wasm32-freestanding

About every 1 in 6 times for me, it deadlocks with this stack trace:

Attaching to process 15445
[New LWP 15446]
[New LWP 15447]
[New LWP 15448]
[New LWP 15449]
^C[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libthread_db.so.1".
0x00007f6078621ee2 in pthread_cond_wait@@GLIBC_2.3.2 ()
   from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
(gdb) thread apply all bt

Thread 5 (Thread 0x7f60764bb700 (LWP 15449)):
#0  0x00007f6078621ee2 in pthread_cond_wait@@GLIBC_2.3.2 () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
#1  0x00007f60785470cc in
std::condition_variable::wait(std::unique_lock<std::mutex>&) () from
/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib/lib/libstdc++.so.6
#2  0x00000000027670b6 in
std::condition_variable::wait<llvm::parallel::detail::Latch::sync()
const::{lambda()#1}>(std::unique_lock<std::mutex>&,
llvm::parallel::detail::Latch::sync() const::{lambda()#1}) (
    this=0x7f60764bab30, __lock=..., __p=...) at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/condition_variable:99
#3  0x0000000002765b5c in llvm::parallel::detail::Latch::sync
(this=0x7f60764bab00) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:71
#4  0x0000000002765af2 in llvm::parallel::detail::Latch::~Latch
(this=0x7f60764bab00, __in_chrg=<optimized out>) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:56
#5  0x0000000002770004 in llvm::parallel::detail::TaskGroup::~TaskGroup
(this=0x7f60764bab00, __in_chrg=<optimized out>)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:75
#6  0x0000000002ac9d52 in
llvm::parallel::detail::parallel_for_each<lld::wasm::InputSection* const*,
lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(lld::wasm::InputSection * const *,
lld::wasm::InputSection * const *, lld::wasm::CustomSection::<lambda(const
lld::wasm::InputSection*)>) (Begin=0x519ff88, End=0x519ff90, Fn=...)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:160
#7  0x0000000002ac983d in llvm::parallel::for_each<lld::wasm::InputSection*
const*, lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(llvm::parallel::parallel_execution_policy,
lld::wasm::InputSection * const *, lld::wasm::InputSection * const *,
lld::wasm::CustomSection::<lambda(const lld::wasm::InputSection*)>)
(policy=..., Begin=0x519ff80, End=0x519ff90, Fn=...)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:234
#8  0x0000000002ac970e in
lld::parallelForEach<llvm::ArrayRef<lld::wasm::InputSection*>&,
lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(llvm::ArrayRef<lld::wasm::InputSection*> &,
lld::wasm::CustomSection::<lambda(const lld::wasm::InputSection*)>) (Range=...,
Fn=...) at /home/andy/downloads/zig/deps/lld/include/lld/Common/Threads.h:71
#9  0x0000000002ac948b in lld::wasm::CustomSection::writeTo (this=0x51c9080,
Buf=0x7f6077cc52eb "") at
/home/andy/downloads/zig/deps/lld/wasm/OutputSections.cpp:235
#10 0x0000000002aaaa15 in (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>::operator()(lld::wasm::OutputSection
*) const (__closure=0x7f60764badc8, S=0x51c9080)
    at /home/andy/downloads/zig/deps/lld/wasm/Writer.cpp:662
#11 0x0000000002ab0ada in
std::for_each<__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >, (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>
>(__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >,
__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >, (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>) (__first=0x51c9080,
__last=0x51c9110, __f=...)
    at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/bits/stl_algo.h:3884
#12 0x0000000002ab094e in llvm::parallel::detail::<lambda()>::operator()(void)
const (__closure=0x7f6060000b50) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:162
#13 0x0000000002ab2367 in std::_Function_handler<void(),
llvm::parallel::detail::parallel_for_each(IterTy, IterTy, FuncTy) [with IterTy
= __gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >; FuncTy = (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>]::<lambda()>
>::_M_invoke(const std::_Any_data &) (__functor=...)
    at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/bits/std_function.h:316
#14 0x00007f607912f336 in std::_Function_handler<void (),
llvm::parallel::detail::TaskGroup::spawn(std::function<void
()>)::{lambda()#1}>::_M_invoke(std::_Any_data const&) ()
   from
/nix/store/6h1hah8ndjxvij0r8xn0f5qb88vyv0hr-llvm-8.0.0-lib/lib/libLLVM-8.so
#15 0x00007f607912f4b5 in
std::thread::_State_impl<std::thread::_Invoker<std::tuple<(anonymous
namespace)::ThreadPoolExecutor::ThreadPoolExecutor(unsigned
int)::{lambda()#1}::operator()() const::{lambda()#1}> > >::_M_run() () from
/nix/store/6h1hah8ndjxvij0r8xn0f5qb88vyv0hr-llvm-8.0.0-lib/lib/libLLVM-8.so
#16 0x00007f607854cd7f in ?? () from
/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib/lib/libstdc++.so.6
#17 0x00007f607861bef7 in start_thread () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
#18 0x00007f607801922f in clone () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libc.so.6

Thread 4 (Thread 0x7f6076cbc700 (LWP 15448)):
#0  0x00007f6078621ee2 in pthread_cond_wait@@GLIBC_2.3.2 () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
#1  0x00007f60785470cc in
std::condition_variable::wait(std::unique_lock<std::mutex>&) () from
/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib/lib/libstdc++.so.6
#2  0x00000000027670b6 in
std::condition_variable::wait<llvm::parallel::detail::Latch::sync()
const::{lambda()#1}>(std::unique_lock<std::mutex>&,
llvm::parallel::detail::Latch::sync() const::{lambda()#1}) (
    this=0x7f6076cbbb30, __lock=..., __p=...) at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/condition_variable:99
#3  0x0000000002765b5c in llvm::parallel::detail::Latch::sync
(this=0x7f6076cbbb00) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:71
#4  0x0000000002765af2 in llvm::parallel::detail::Latch::~Latch
(this=0x7f6076cbbb00, __in_chrg=<optimized out>) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:56
#5  0x0000000002770004 in llvm::parallel::detail::TaskGroup::~TaskGroup
(this=0x7f6076cbbb00, __in_chrg=<optimized out>)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:75
#6  0x0000000002ac9d52 in
llvm::parallel::detail::parallel_for_each<lld::wasm::InputSection* const*,
lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(lld::wasm::InputSection * const *,
lld::wasm::InputSection * const *, lld::wasm::CustomSection::<lambda(const
lld::wasm::InputSection*)>) (Begin=0x516d8f8, End=0x516d900, Fn=...)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:160
#7  0x0000000002ac983d in llvm::parallel::for_each<lld::wasm::InputSection*
const*, lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(llvm::parallel::parallel_execution_policy,
lld::wasm::InputSection * const *, lld::wasm::InputSection * const *,
lld::wasm::CustomSection::<lambda(const lld::wasm::InputSection*)>)
(policy=..., Begin=0x516d8f0, End=0x516d900, Fn=...)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:234
#8  0x0000000002ac970e in
lld::parallelForEach<llvm::ArrayRef<lld::wasm::InputSection*>&,
lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(llvm::ArrayRef<lld::wasm::InputSe--Type <RET> for
more, q to quit, c to continue without paging--
ction*> &, lld::wasm::CustomSection::<lambda(const lld::wasm::InputSection*)>)
(Range=..., Fn=...) at
/home/andy/downloads/zig/deps/lld/include/lld/Common/Threads.h:71
#9  0x0000000002ac948b in lld::wasm::CustomSection::writeTo (this=0x51c9110,
Buf=0x7f6077cc5554 "") at
/home/andy/downloads/zig/deps/lld/wasm/OutputSections.cpp:235
#10 0x0000000002aaaa15 in (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>::operator()(lld::wasm::OutputSection
*) const (__closure=0x7f6076cbbdc8, S=0x51c9110)
    at /home/andy/downloads/zig/deps/lld/wasm/Writer.cpp:662
#11 0x0000000002ab0ada in
std::for_each<__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >, (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>
>(__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >,
__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >, (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>) (__first=0x51c9110,
__last=0x51c91a0, __f=...)
    at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/bits/stl_algo.h:3884
#12 0x0000000002ab094e in llvm::parallel::detail::<lambda()>::operator()(void)
const (__closure=0x7f606c000b50) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:162
#13 0x0000000002ab2367 in std::_Function_handler<void(),
llvm::parallel::detail::parallel_for_each(IterTy, IterTy, FuncTy) [with IterTy
= __gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >; FuncTy = (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>]::<lambda()>
>::_M_invoke(const std::_Any_data &) (__functor=...)
    at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/bits/std_function.h:316
#14 0x00007f607912f336 in std::_Function_handler<void (),
llvm::parallel::detail::TaskGroup::spawn(std::function<void
()>)::{lambda()#1}>::_M_invoke(std::_Any_data const&) ()
   from
/nix/store/6h1hah8ndjxvij0r8xn0f5qb88vyv0hr-llvm-8.0.0-lib/lib/libLLVM-8.so
#15 0x00007f607912f4b5 in
std::thread::_State_impl<std::thread::_Invoker<std::tuple<(anonymous
namespace)::ThreadPoolExecutor::ThreadPoolExecutor(unsigned
int)::{lambda()#1}::operator()() const::{lambda()#1}> > >::_M_run() () from
/nix/store/6h1hah8ndjxvij0r8xn0f5qb88vyv0hr-llvm-8.0.0-lib/lib/libLLVM-8.so
#16 0x00007f607854cd7f in ?? () from
/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib/lib/libstdc++.so.6
#17 0x00007f607861bef7 in start_thread () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
#18 0x00007f607801922f in clone () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libc.so.6

Thread 3 (Thread 0x7f60774bd700 (LWP 15447)):
#0  0x00007f6078621ee2 in pthread_cond_wait@@GLIBC_2.3.2 () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
#1  0x00007f60785470cc in
std::condition_variable::wait(std::unique_lock<std::mutex>&) () from
/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib/lib/libstdc++.so.6
#2  0x00000000027670b6 in
std::condition_variable::wait<llvm::parallel::detail::Latch::sync()
const::{lambda()#1}>(std::unique_lock<std::mutex>&,
llvm::parallel::detail::Latch::sync() const::{lambda()#1}) (
    this=0x7f60774bcb30, __lock=..., __p=...) at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/condition_variable:99
#3  0x0000000002765b5c in llvm::parallel::detail::Latch::sync
(this=0x7f60774bcb00) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:71
#4  0x0000000002765af2 in llvm::parallel::detail::Latch::~Latch
(this=0x7f60774bcb00, __in_chrg=<optimized out>) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:56
#5  0x0000000002770004 in llvm::parallel::detail::TaskGroup::~TaskGroup
(this=0x7f60774bcb00, __in_chrg=<optimized out>)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:75
#6  0x0000000002ac9d52 in
llvm::parallel::detail::parallel_for_each<lld::wasm::InputSection* const*,
lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(lld::wasm::InputSection * const *,
lld::wasm::InputSection * const *, lld::wasm::CustomSection::<lambda(const
lld::wasm::InputSection*)>) (Begin=0x516d8b8, End=0x516d8c0, Fn=...)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:160
#7  0x0000000002ac983d in llvm::parallel::for_each<lld::wasm::InputSection*
const*, lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(llvm::parallel::parallel_execution_policy,
lld::wasm::InputSection * const *, lld::wasm::InputSection * const *,
lld::wasm::CustomSection::<lambda(const lld::wasm::InputSection*)>)
(policy=..., Begin=0x516d8b0, End=0x516d8c0, Fn=...)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:234
#8  0x0000000002ac970e in
lld::parallelForEach<llvm::ArrayRef<lld::wasm::InputSection*>&,
lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(llvm::ArrayRef<lld::wasm::InputSection*> &,
lld::wasm::CustomSection::<lambda(const lld::wasm::InputSection*)>) (Range=...,
Fn=...) at /home/andy/downloads/zig/deps/lld/include/lld/Common/Threads.h:71
#9  0x0000000002ac948b in lld::wasm::CustomSection::writeTo (this=0x51c9230,
Buf=0x7f6077cc7815 "") at
/home/andy/downloads/zig/deps/lld/wasm/OutputSections.cpp:235
#10 0x0000000002aaaa15 in (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>::operator()(lld::wasm::OutputSection
*) const (__closure=0x7f60774bcdc8, S=0x51c9230)
    at /home/andy/downloads/zig/deps/lld/wasm/Writer.cpp:662
#11 0x0000000002ab0ada in
std::for_each<__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >, (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>
>(__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >,
__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >, (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>) (__first=0x51c9230,
__last=0x51b8238, __f=...)
    at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/bits/stl_algo.h:3884
#12 0x0000000002ab094e in llvm::parallel::detail::<lambda()>::operator()(void)
const (__closure=0x7f6068000b50) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:162
#13 0x0000000002ab2367 in std::_Function_handler<void(),
llvm::parallel::detail::parallel_for_each(IterTy, IterTy, FuncTy) [with IterTy
= __gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >; FuncTy = (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>]::<lambda()>
>::_M_invoke(const std::_Any_data &) (__functor=...)
    at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/bits/std_function.h:316
#14 0x00007f607912f336 in std::_Function_handler<void (),
llvm::parallel::detail::TaskGroup::spawn(std::function<void
()>)::{lambda()#1}>::_M_invoke(std::_Any_data const&) ()
   from
/nix/store/6h1hah8ndjxvij0r8xn0f5qb88vyv0hr-llvm-8.0.0-lib/lib/libLLVM-8.so
#15 0x00007f607912f4b5 in
std::thread::_State_impl<std::thread::_Invoker<std::tuple<(anonymous
namespace)::ThreadPoolExecutor::ThreadPoolExecutor(unsigned
int)::{lambda()#1}::operator()() const::{lambda()#1}> > >::_M_run() () from
/nix/store/6h1hah8ndjxvij0r8xn0f5qb88vyv0hr-llvm-8.0.0-lib/lib/libLLVM-8.so
#16 0x00007f607854cd7f in ?? () from
/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib/lib/libstdc++.so.6
--Type <RET> for more, q to quit, c to continue without paging--
#17 0x00007f607861bef7 in start_thread () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
#18 0x00007f607801922f in clone () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libc.so.6

Thread 2 (Thread 0x7f6077cbe700 (LWP 15446)):
#0  0x00007f6078621ee2 in pthread_cond_wait@@GLIBC_2.3.2 () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
#1  0x00007f60785470cc in
std::condition_variable::wait(std::unique_lock<std::mutex>&) () from
/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib/lib/libstdc++.so.6
#2  0x00000000027670b6 in
std::condition_variable::wait<llvm::parallel::detail::Latch::sync()
const::{lambda()#1}>(std::unique_lock<std::mutex>&,
llvm::parallel::detail::Latch::sync() const::{lambda()#1}) (
    this=0x7f6077cbdb20, __lock=..., __p=...) at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/condition_variable:99
#3  0x0000000002765b5c in llvm::parallel::detail::Latch::sync
(this=0x7f6077cbdaf0) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:71
#4  0x0000000002765af2 in llvm::parallel::detail::Latch::~Latch
(this=0x7f6077cbdaf0, __in_chrg=<optimized out>) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:56
#5  0x0000000002770004 in llvm::parallel::detail::TaskGroup::~TaskGroup
(this=0x7f6077cbdaf0, __in_chrg=<optimized out>)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:75
#6  0x0000000002ac9d52 in
llvm::parallel::detail::parallel_for_each<lld::wasm::InputSection* const*,
lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(lld::wasm::InputSection * const *,
lld::wasm::InputSection * const *, lld::wasm::CustomSection::<lambda(const
lld::wasm::InputSection*)>) (Begin=0x516d978, End=0x516d980, Fn=...)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:160
#7  0x0000000002ac983d in llvm::parallel::for_each<lld::wasm::InputSection*
const*, lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(llvm::parallel::parallel_execution_policy,
lld::wasm::InputSection * const *, lld::wasm::InputSection * const *,
lld::wasm::CustomSection::<lambda(const lld::wasm::InputSection*)>)
(policy=..., Begin=0x516d970, End=0x516d980, Fn=...)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:234
#8  0x0000000002ac970e in
lld::parallelForEach<llvm::ArrayRef<lld::wasm::InputSection*>&,
lld::wasm::CustomSection::writeTo(uint8_t*)::<lambda(const
lld::wasm::InputSection*)> >(llvm::ArrayRef<lld::wasm::InputSection*> &,
lld::wasm::CustomSection::<lambda(const lld::wasm::InputSection*)>) (Range=...,
Fn=...) at /home/andy/downloads/zig/deps/lld/include/lld/Common/Threads.h:71
#9  0x0000000002ac948b in lld::wasm::CustomSection::writeTo (this=0x51c91a0,
Buf=0x7f6077cc7226 "") at
/home/andy/downloads/zig/deps/lld/wasm/OutputSections.cpp:235
#10 0x0000000002aaaa15 in (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>::operator()(lld::wasm::OutputSection
*) const (__closure=0x7f6077cbddb8, S=0x51c91a0)
    at /home/andy/downloads/zig/deps/lld/wasm/Writer.cpp:662
#11 0x0000000002ab0ada in
std::for_each<__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >, (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>
>(__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >,
__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >, (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>) (__first=0x51c91a0,
__last=0x51c9230, __f=...)
    at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/bits/stl_algo.h:3884
#12 0x0000000002ab094e in llvm::parallel::detail::<lambda()>::operator()(void)
const (__closure=0x7f6070000fa0) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:162
#13 0x0000000002ab2367 in std::_Function_handler<void(),
llvm::parallel::detail::parallel_for_each(IterTy, IterTy, FuncTy) [with IterTy
= __gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >; FuncTy = (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>]::<lambda()>
>::_M_invoke(const std::_Any_data &) (__functor=...)
    at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/bits/std_function.h:316
#14 0x00007f607912f336 in std::_Function_handler<void (),
llvm::parallel::detail::TaskGroup::spawn(std::function<void
()>)::{lambda()#1}>::_M_invoke(std::_Any_data const&) ()
   from
/nix/store/6h1hah8ndjxvij0r8xn0f5qb88vyv0hr-llvm-8.0.0-lib/lib/libLLVM-8.so
#15 0x00007f607912faad in
std::thread::_State_impl<std::thread::_Invoker<std::tuple<(anonymous
namespace)::ThreadPoolExecutor::ThreadPoolExecutor(unsigned int)::{lambda()#1}>
> >::_M_run() ()
   from
/nix/store/6h1hah8ndjxvij0r8xn0f5qb88vyv0hr-llvm-8.0.0-lib/lib/libLLVM-8.so
#16 0x00007f607854cd7f in ?? () from
/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib/lib/libstdc++.so.6
#17 0x00007f607861bef7 in start_thread () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
#18 0x00007f607801922f in clone () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libc.so.6

Thread 1 (Thread 0x7f6077d0a740 (LWP 15445)):
#0  0x00007f6078621ee2 in pthread_cond_wait@@GLIBC_2.3.2 () from
/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0
#1  0x00007f60785470cc in
std::condition_variable::wait(std::unique_lock<std::mutex>&) () from
/nix/store/hlnxw4k6931bachvg5sv0cyaissimswb-gcc-7.4.0-lib/lib/libstdc++.so.6
#2  0x00000000027670b6 in
std::condition_variable::wait<llvm::parallel::detail::Latch::sync()
const::{lambda()#1}>(std::unique_lock<std::mutex>&,
llvm::parallel::detail::Latch::sync() const::{lambda()#1}) (
    this=0x7ffd54a7f310, __lock=..., __p=...) at
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/include/c++/7.4.0/condition_variable:99
#3  0x0000000002765b5c in llvm::parallel::detail::Latch::sync
(this=0x7ffd54a7f2e0) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:71
#4  0x0000000002765af2 in llvm::parallel::detail::Latch::~Latch
(this=0x7ffd54a7f2e0, __in_chrg=<optimized out>) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:56
#5  0x0000000002770004 in llvm::parallel::detail::TaskGroup::~TaskGroup
(this=0x7ffd54a7f2e0, __in_chrg=<optimized out>)
    at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:75
#6  0x0000000002ab0a8e in
llvm::parallel::detail::parallel_for_each<__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >, (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>
>(__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >,
__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >, (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>) (Begin=0x51b8238, 
    End=0x519c6d8, Fn=...) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:160
#7  0x0000000002aafbad in
llvm::parallel::for_each<__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*> >, (anonymous
namespace)::Writer::writeSections()::<lambda(lld::--Type <RET> for more, q to
quit, c to continue without paging--
wasm::OutputSection*)> >(llvm::parallel::parallel_execution_policy,
__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >,
__gnu_cxx::__normal_iterator<lld::wasm::OutputSection**,
std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > >, (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>)
    (policy=..., Begin=0x51b7da0, End=0x519c6d8, Fn=...) at
/nix/store/7c7w734amha8y5r7rhp7nxpvchbpds2y-llvm-8.0.0/include/llvm/Support/Parallel.h:234
#8  0x0000000002aaf431 in
lld::parallelForEach<std::vector<lld::wasm::OutputSection*>&, (anonymous
namespace)::Writer::writeSections()::<lambda(lld::wasm::OutputSection*)>
>(std::vector<lld::wasm::OutputSection*,
std::allocator<lld::wasm::OutputSection*> > &, (anonymous
namespace)::Writer::<lambda(lld::wasm::OutputSection*)>) (Range=std::vector of
length 18, capacity 32 = {...}, Fn=...)
    at /home/andy/downloads/zig/deps/lld/include/lld/Common/Threads.h:71
#9  0x0000000002aaaa5f in (anonymous namespace)::Writer::writeSections
(this=0x7ffd54a7f8a0) at /home/andy/downloads/zig/deps/lld/wasm/Writer.cpp:662
#10 0x0000000002aae860 in (anonymous namespace)::Writer::run
(this=0x7ffd54a7f8a0) at /home/andy/downloads/zig/deps/lld/wasm/Writer.cpp:1192
#11 0x0000000002aaeed5 in lld::wasm::writeResult () at
/home/andy/downloads/zig/deps/lld/wasm/Writer.cpp:1223
#12 0x0000000002a841ac in (anonymous namespace)::LinkerDriver::link
(this=0x7ffd54a800d0, ArgsArr=...) at
/home/andy/downloads/zig/deps/lld/wasm/Driver.cpp:620
#13 0x0000000002a80c96 in lld::wasm::link (Args=..., CanExitEarly=false,
Error=...) at /home/andy/downloads/zig/deps/lld/wasm/Driver.cpp:93
#14 0x0000000000ddb3ba in ZigLLDLink (oformat=ZigLLVM_Wasm, args=0x517ce70,
arg_count=10, append_diagnostic=0xda60b3 <link_diag_callback(void*, char
const*, size_t)>, context=0x7ffd54a80240)
    at /home/andy/downloads/zig/src/zig_llvm.cpp:925
#15 0x0000000000da612f in zig_lld_link (oformat=ZigLLVM_Wasm, args=0x517ce70,
arg_count=10, diag=0x7ffd54a80240) at
/home/andy/downloads/zig/src/link.cpp:1135
#16 0x0000000000da7eb0 in codegen_link (g=0x50b2d70) at
/home/andy/downloads/zig/src/link.cpp:1648
#17 0x0000000000d3304d in codegen_build_and_link (g=0x50b2d70) at
/home/andy/downloads/zig/src/codegen.cpp:9403
#18 0x0000000000dad438 in main (argc=5, argv=0x7ffd54a80b88) at
/home/andy/downloads/zig/src/main.cpp:1142


Downstream bug report: https://github.com/ziglang/zig/issues/2283

I have attached a repro. To use the attached files for the repro:

wasm-ld -error-limit=0 --no-entry --allow-undefined --export-all -o ./test.wasm
./test.o libbuiltin.a libcompiler_rt.a

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to