Bug#827866: clang: __atomic_test_and_set provokes clang++ crash on aarch64-linux-gnu target

Marco Milanese marcomilanese7 at gmail.com
Tue Jun 21 21:26:25 UTC 2016


Package: clang
Version: 1:3.6-33
Severity: normal

Dear Maintainer,

When I try to cross compile (target=aarch64-linux-gnu) the following C++ code,
clang++ crashes:

mm7 at pc5:~$ cat test.cpp
bool testAndSet(void *atomic) {
    return __atomic_test_and_set(atomic, __ATOMIC_SEQ_CST);
}

This is the output of clang++ invocation:

mm7 at pc5:~$ clang++ -target aarch64-linux-gnu test.cpp
0  libLLVM-3.6.so.1 0x00007f1e7136ef72 llvm::sys::PrintStackTrace(_IO_FILE*) +
34
1  libLLVM-3.6.so.1 0x00007f1e7136d779
2  libpthread.so.0  0x00007f1e7001cd40
3  libLLVM-3.6.so.1 0x00007f1e70e53177
llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand
const&) + 23
4  libLLVM-3.6.so.1 0x00007f1e71729a1d
llvm::AArch64InstrInfo::storeRegToStackSlot(llvm::MachineBasicBlock&,
llvm::MachineBasicBlock::bundle_iterator<llvm::MachineInstr,
llvm::ilist_iterator<llvm::MachineInstr> >, unsigned int, bool, int,
llvm::TargetRegisterClass const*, llvm::TargetRegisterInfo const*) const + 1565
5  libLLVM-3.6.so.1 0x00007f1e70ec01e7
6  libLLVM-3.6.so.1 0x00007f1e70ec2e51
7  libLLVM-3.6.so.1 0x00007f1e70ec49b0
8  libLLVM-3.6.so.1 0x00007f1e70a347b7
llvm::FPPassManager::runOnFunction(llvm::Function&) + 471
9  libLLVM-3.6.so.1 0x00007f1e70a34a0b
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
10 libLLVM-3.6.so.1 0x00007f1e70a34444
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 756
11 clang            0x0000000000849e7b
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) +
3323
12 clang            0x000000000083a936
13 clang            0x00000000009edd5a clang::ParseAST(clang::Sema&, bool,
bool) + 778
14 clang            0x00000000006bc786 clang::FrontendAction::Execute() + 118
15 clang            0x0000000000696989
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 297
16 clang            0x000000000067df23
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1923
17 clang            0x00000000006794d8 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 1256
18 clang            0x00000000006765ef main + 927
19 libc.so.6        0x00007f1e6eb835f0 __libc_start_main + 240
20 clang            0x0000000000678b0f
Stack dump:
0.      Program arguments: /usr/lib/llvm-3.6/bin/clang -cc1 -triple aarch64
--linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-
file-name test.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-
elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-
cpu generic -target-feature +neon -target-abi aapcs -target-linker-version
2.25.1 -dwarf-column-info -resource-dir
/usr/lib/llvm-3.6/bin/../lib/clang/3.6.2 -internal-isystem /usr/bin/../lib/gcc-
cross/aarch64-linux-gnu/5.3.1/../../../../aarch64-linux-gnu/include/c++/5.3.1
-internal-isystem /usr/bin/../lib/gcc-cross/aarch64-linux-
gnu/5.3.1/../../../../aarch64-linux-gnu/include/c++/5.3.1/aarch64-linux-gnu
-internal-isystem /usr/bin/../lib/gcc-cross/aarch64-linux-
gnu/5.3.1/../../../../aarch64-linux-gnu/include/c++/5.3.1/backward -internal-
isystem /usr/local/include -internal-isystem
/usr/lib/llvm-3.6/bin/../lib/clang/3.6.2/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-
compilation-dir /home/mm7 -ferror-limit 19 -fmessage-length 158 -mstackrealign
-fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -fcxx-
exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp
/test-ceff95.o -x c++ test.cpp
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'test.cpp'.
4.      Running pass 'Fast Register Allocator' on function '@_Z10testAndSetPv'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
Debian clang version 3.6.2-3 (tags/RELEASE_362/final) (based on LLVM 3.6.2)
Target: aarch64--linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://bugs.debian.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-f84ba6.cpp
clang: note: diagnostic msg: /tmp/test-f84ba6.sh
clang: note: diagnostic msg:

********************
mm7 at pc5:~$ cat /tmp/test-f84ba6.cpp
# 1 "<built-in>"
# 1 "test.cpp"
bool testAndSet(void *atomic) {
    return __atomic_test_and_set(atomic, __ATOMIC_SEQ_CST);
}
mm7 at pc5:~$ cat /tmp/test-f84ba6.sh
 "/usr/lib/llvm-3.6/bin/clang" "-cc1" "-triple" "aarch64--linux-gnu" "-emit-
obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-main-file-name"
"test.cpp" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-
fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-fuse-init-
array" "-target-cpu" "generic" "-target-feature" "+neon" "-target-abi" "aapcs"
"-target-linker-version" "2.25.1" "-dwarf-column-info" "-fdeprecated-macro"
"-ferror-limit" "19" "-fmessage-length" "158" "-mstackrealign" "-fallow-half-
arguments-and-returns" "-fno-signed-char" "-fobjc-runtime=gcc" "-fcxx-
exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics"
"-x" "c++" "test-f84ba6.cpp"
mm7 at pc5:~$

Note: the same code compiles without errors for x86_64:
mm7 at pc5:~$ clang++ test.cpp -c
mm7 at pc5:~$ file test.o
test.o: ELF 64-bit LSB relocatable, x86-64, version 1 (GNU/Linux), not stripped
mm7 at pc5:~$

Thank you very much,
Regards,

Marco Milanese



-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages clang depends on:
ii  clang-3.6  1:3.6.2-3

clang recommends no packages.

clang suggests no packages.

-- debconf-show failed



More information about the Pkg-llvm-team mailing list