Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to link against zig library with --bundle-compiler-rt throwing bad_alloc() on alpine linux aarch64 #4822

Closed
andrewrk opened this issue Mar 26, 2020 · 0 comments · Fixed by #4832
Labels
arch-aarch64 64-bit ARM bug Observed behavior contradicts documented or intended behavior os-linux
Milestone

Comments

@andrewrk
Copy link
Member

Steps to reproduce:

  • remove the workaround from the Drone CI script that I'm about to add.

Backtrace:

/zig/build-debug # ninja install
[167/168] Install the project...
-- Install configuration: "Debug"
-- Installing: /zig/dist/bin/zig
-- Set runtime path of "/zig/dist/bin/zig" to ""
-- Installing: /zig/dist/lib
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
::
:: ERROR: Child aborted
:: (execute_process)
::
:: argv: /zig/build-debug/zig build --override-lib-dir /zig/lib -Dlib-files-only --prefix /zig/dist install
::
:: argv[0]: /zig/build-debug/zig
:: argv[1]: build
:: argv[2]: --override-lib-dir
:: argv[3]: /zig/lib
:: argv[4]: -Dlib-files-only
:: argv[5]: --prefix
:: argv[6]: /zig/dist
:: argv[7]: install
::
CMake Error at /zig/cmake/install.cmake:36 (message):
Call Stack (most recent call first):
  cmake_install.cmake:73 (include)


FAILED: CMakeFiles/install.util 
cd /zig/build-debug && /usr/bin/cmake -P cmake_install.cmake
ninja: build stopped: subcommand failed.
/zig/build-debug # gdb ./zig -ex 'run build --override-lib-dir /zig/lib -Dlib-files-only --prefix /zig/d
ist install'
GNU gdb (GDB) 8.3.1
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./zig...
Starting program: /zig/build-debug/zig build --override-lib-dir /zig/lib -Dlib-files-only --prefix /zig/dist install
warning: Error disabling address space randomization: Operation not permitted
LLVM Emit Output...terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Program received signal SIGABRT, Aborted.
0x0000ffff85638a90 in sigsetjmp () from /lib/ld-musl-aarch64.so.1
(gdb) bt
#0  0x0000ffff85638a90 in sigsetjmp () from /lib/ld-musl-aarch64.so.1
#1  0x0000ffff85638c24 in raise () from /lib/ld-musl-aarch64.so.1
#2  0x0000ffff8560ddf0 in abort () from /lib/ld-musl-aarch64.so.1
#3  0x0000ffff85502d88 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#4  0x0000ffff85500e14 in __cxxabiv1::__terminate(void (*)()) () from /usr/lib/libstdc++.so.6
#5  0x0000ffff85500e7c in std::terminate() () from /usr/lib/libstdc++.so.6
#6  0x0000ffff85501120 in __cxa_throw () from /usr/lib/libstdc++.so.6
#7  0x0000ffff854fd71c in std::__throw_bad_alloc() () from /usr/lib/libstdc++.so.6
#8  0x0000aaaab470de70 in __gnu_cxx::new_allocator<std::__detail::_Hash_node_base*>::allocate (
    this=0xffffc1443300, __n=18446744073709551557) at /usr/include/c++/9.2.0/ext/new_allocator.h:105
#9  0x0000aaaab470ddfc in std::allocator_traits<std::allocator<std::__detail::_Hash_node_base*> >::allocate (__a=..., __n=18446744073709551557) at /usr/include/c++/9.2.0/bits/alloc_traits.h:444
#10 0x0000aaaab67330d4 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<llvm::DILocalScope const* const, llvm::LexicalScope>, false> > >::_M_allocate_buckets (
    this=0xaaab103fe520, __n=18446744073709551557)
    at /usr/include/c++/9.2.0/bits/hashtable_policy.h:2134
#11 0x0000aaaab6732ea0 in std::_Hashtable<llvm::DILocalScope const*, std::pair<llvm::DILocalScope const* const, llvm::LexicalScope>, std::allocator<std::pair<llvm::DILocalScope const* const, llvm::LexicalScope> >, std::__detail::_Select1st, std::equal_to<llvm::DILocalScope const*>, std::hash<llvm::DILocalScope const*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_allocate_buckets (
    this=0xaaab103fe520, __n=18446744073709551557) at /usr/include/c++/9.2.0/bits/hashtable.h:361
#12 0x0000aaaab67327bc in std::_Hashtable<llvm::DILocalScope const*, std::pair<llvm::DILocalScope const* const, llvm::LexicalScope>, std::allocator<std::pair<llvm::DILocalScope const* const, llvm::LexicalScope> >, std::__detail::_Select1st, std::equal_to<llvm::DILocalScope const*>, std::hash<llvm::DILocalScope const*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_rehash_aux (
    this=0xaaab103fe520, __n=18446744073709551557) at /usr/include/c++/9.2.0/bits/hashtable.h:2088
#13 0x0000aaaab6731eec in std::_Hashtable<llvm::DILocalScope const*, std::pair<llvm::DILocalScope const* const, llvm::LexicalScope>, std::allocator<std::pair<llvm::DILocalScope const* const, llvm::LexicalScope> >, std::__detail::_Select1st, std::equal_to<llvm::DILocalScope const*>, std::hash<llvm::DILocalScope const*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_rehash (this=0xaaab103fe520, 
    __n=18446744073709551557, __state=@0xffffc1443438: 0)
    at /usr/include/c++/9.2.0/bits/hashtable.h:2067
#14 0x0000aaaab67315b4 in std::_Hashtable<llvm::DILocalScope const*, std::pair<llvm::DILocalScope const* const, llvm::LexicalScope>, std::allocator<std::pair<llvm::DILocalScope const* const, llvm::LexicalScope> >, std::__detail::_Select1st, std::equal_to<llvm::DILocalScope const*>, std::hash<llvm::DILocalScope const*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_insert_unique_node (
    this=0xaaab103fe520, __bkt=0, __code=187651666363232, __node=0xaaab11664e20, __n_elt=1)
    at /usr/include/c++/9.2.0/bits/hashtable.h:1713
#15 0x0000aaaab6730b58 in std::_Hashtable<llvm::DILocalScope const*, std::pair<llvm::DILocalScope const* const, llvm::LexicalScope>, std::allocator<std::pair<llvm::DILocalScope const* const, llvm::LexicalScope> >, std::__detail::_Select1st, std::equal_to<llvm::DILocalScope const*>, std::hash<llvm::DILocalScope const*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_emplace<std::piecewise_construct_t const&, std::tuple<llvm::DILocalScope const*&>, std::tuple<llvm::LexicalScope*&, llvm::DILocalScope const*&, decltype(nullptr)&&, bool&&> >(std::integral_constant<bool, true>, std::piecewise_construct_t const&, std::tuple<llvm::DILocalScope const*&>&&, std::tuple<llvm::LexicalScope*&, llvm::DILocalScope const*&, decltype(nullptr)&&, bool&&>&&) (this=0xaaab103fe520, __args#0=..., __args#1=..., __args#2=...)
    at /usr/include/c++/9.2.0/bits/hashtable.h:1660
#16 0x0000aaaab672ff70 in std::_Hashtable<llvm::DILocalScope const*, std::pair<llvm::DILocalScope const*--Type <RET> for more, q to quit, c to continue without paging--
 const, llvm::LexicalScope>, std::allocator<std::pair<llvm::DILocalScope const* const, llvm::LexicalScope> >, std::__detail::_Select1st, std::equal_to<llvm::DILocalScope const*>, std::hash<llvm::DILocalScope const*>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::emplace<std::piecewise_construct_t const&, std::tuple<llvm::DILocalScope const*&>, std::tuple<llvm::LexicalScope*&, llvm::DILocalScope const*&, decltype(nullptr)&&, bool&&> >(std::piecewise_construct_t const&, std::tuple<llvm::DILocalScope const*&>&&, std::tuple<llvm::LexicalScope*&, llvm::DILocalScope const*&, decltype(nullptr)&&, bool&&>&&)
    (this=0xaaab103fe520, __args#0=..., __args#1=..., __args#2=...)
    at /usr/include/c++/9.2.0/bits/hashtable.h:749
#17 0x0000aaaab672f6bc in std::unordered_map<llvm::DILocalScope const*, llvm::LexicalScope, std::hash<llvm::DILocalScope const*>, std::equal_to<llvm::DILocalScope const*>, std::allocator<std::pair<llvm::DILocalScope const* const, llvm::LexicalScope> > >::emplace<std::piecewise_construct_t const&, std::tuple<llvm::DILocalScope const*&>, std::tuple<llvm::LexicalScope*&, llvm::DILocalScope const*&, decltype(nullptr)&&, bool&&> >(std::piecewise_construct_t const&, std::tuple<llvm::DILocalScope const*&>&&, std::tuple<llvm::LexicalScope*&, llvm::DILocalScope const*&, decltype(nullptr)&&, bool&&>&&) (this=0xaaab103fe520, 
    __args#0=..., __args#1=..., __args#2=...) at /usr/include/c++/9.2.0/bits/unordered_map.h:388
#18 0x0000aaaab672df24 in llvm::LexicalScopes::getOrCreateRegularScope (this=0xaaab103fe518, 
    Scope=0xaaab0eea4360) at ../lib/CodeGen/LexicalScopes.cpp:174
#19 0x0000aaaab672ddd8 in llvm::LexicalScopes::getOrCreateLexicalScope (this=0xaaab103fe518, 
    Scope=0xaaab0eea4360, IA=0x0) at ../lib/CodeGen/LexicalScopes.cpp:154
#20 0x0000aaaab672dec4 in llvm::LexicalScopes::getOrCreateRegularScope (this=0xaaab103fe518, 
    Scope=0xaaab0eea4970) at ../lib/CodeGen/LexicalScopes.cpp:170
#21 0x0000aaaab672ddd8 in llvm::LexicalScopes::getOrCreateLexicalScope (this=0xaaab103fe518, 
    Scope=0xaaab0eea4970, IA=0x0) at ../lib/CodeGen/LexicalScopes.cpp:154
#22 0x0000aaaab672dec4 in llvm::LexicalScopes::getOrCreateRegularScope (this=0xaaab103fe518, 
    Scope=0xaaab0eea49b0) at ../lib/CodeGen/LexicalScopes.cpp:170
#23 0x0000aaaab672ddd8 in llvm::LexicalScopes::getOrCreateLexicalScope (this=0xaaab103fe518, 
    Scope=0xaaab0eea49b0, IA=0x0) at ../lib/CodeGen/LexicalScopes.cpp:154
#24 0x0000aaaab672f0ac in llvm::LexicalScopes::getOrCreateLexicalScope (this=0xaaab103fe518, 
    DL=0xaaab0f641528) at ../include/llvm/CodeGen/LexicalScopes.h:209
#25 0x0000aaaab672db54 in llvm::LexicalScopes::extractLexicalScopes (this=0xaaab103fe518, 
    MIRanges=..., MI2ScopeMap=...) at ../lib/CodeGen/LexicalScopes.cpp:100
#26 0x0000aaaab672d984 in llvm::LexicalScopes::initialize (this=0xaaab103fe518, Fn=...)
    at ../lib/CodeGen/LexicalScopes.cpp:59
#27 0x0000aaaab6739aa4 in (anonymous namespace)::LiveDebugValues::runOnMachineFunction (
    this=0xaaab103fe480, MF=...) at ../lib/CodeGen/LiveDebugValues.cpp:1639
#28 0x0000aaaab6810c00 in llvm::MachineFunctionPass::runOnFunction (this=0xaaab103fe480, F=...)
    at ../lib/CodeGen/MachineFunctionPass.cpp:73
#29 0x0000aaaab7878dc4 in llvm::FPPassManager::runOnFunction (this=0xaaab101ffc00, F=...)
    at ../lib/IR/LegacyPassManager.cpp:1481
#30 0x0000aaaab7879010 in llvm::FPPassManager::runOnModule (this=0xaaab101ffc00, M=...)
    at ../lib/IR/LegacyPassManager.cpp:1517
#31 0x0000aaaab7879414 in (anonymous namespace)::MPPassManager::runOnModule (this=0xaaab12c1dd40, 
    M=...) at ../lib/IR/LegacyPassManager.cpp:1582
#32 0x0000aaaab7879b44 in llvm::legacy::PassManagerImpl::run (this=0xaaab0f03faa0, M=...)
    at ../lib/IR/LegacyPassManager.cpp:1694
#33 0x0000aaaab7879d74 in llvm::legacy::PassManager::run (this=0xffffc1443dd0, M=...)
    at ../lib/IR/LegacyPassManager.cpp:1725
#34 0x0000aaaab246c484 in ZigLLVMTargetMachineEmitToFile (targ_machine_ref=0xaaaadc4326c0, 
    module_ref=0xaaaadc426620, error_message=0xffffc1443f40, is_debug=true, is_small=false, 
    time_report=false, asm_filename=0x0, 
    bin_filename=0xaaab00f337a0 "/zig/zig-cache/o/fTTl3lI7WwB6XlHoC0YAL8SkEc4pDXuoxNLXdHK1JkXyReuJIYnxht-A-HPaKWxO/build.o", llvm_ir_filename=0x0) at ../src/zig_llvm.cpp:268
--Type <RET> for more, q to quit, c to continue without paging--
#35 0x0000aaaab20d6f7c in zig_llvm_emit_output (g=0xaaaadc41f440) at ../src/codegen.cpp:8029
#36 0x0000aaaab20e0f50 in codegen_build_and_link (g=0xaaaadc41f440) at ../src/codegen.cpp:10762
#37 0x0000aaaab20b1bd4 in main0 (argc=8, argv=0xffffc14446d8) at ../src/main.cpp:562
#38 0x0000aaaab20b6188 in main (argc=8, argv=0xffffc14446d8) at ../src/main.cpp:1715
(gdb) quit

Appears to be some problem with LLVM's HashTable ending up calling divti3 and everything goes to hell. @LemonBoy spent a few hours looking into it, and may be able to share more details.

This is a prereq for #2443.

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior os-linux arch-aarch64 64-bit ARM labels Mar 26, 2020
@andrewrk andrewrk added this to the 0.7.0 milestone Mar 26, 2020
andrewrk added a commit that referenced this issue Mar 26, 2020
This patch adds a workaround for #4822, disables one failing langref
example, and enables the rest of the test suite.

You win some, you lose some.
LemonBoy added a commit to LemonBoy/zig that referenced this issue Mar 27, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.6.0 Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-aarch64 64-bit ARM bug Observed behavior contradicts documented or intended behavior os-linux
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant