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

-bcf does not compile C++ containing exception handling #26

Closed
jeffcasavant opened this issue Jun 18, 2015 · 6 comments
Closed

-bcf does not compile C++ containing exception handling #26

jeffcasavant opened this issue Jun 18, 2015 · 6 comments
Assignees

Comments

@jeffcasavant
Copy link

I'm having some issues with the BCF pass. When running BCF like this:
clang++ test.cpp -mllvm -bcf

I get:

The unwind destination does not have a landingpad instruction!
  %call3 = invoke dereferenceable(140) %"class.std::basic_ostream"* @_ZNSolsEi(%"class.std::basic_ostream"* @_ZSt4cout, i32 %23)
          to label %invoke.cont2 unwind label %lpad1
The unwind destination does not have a landingpad instruction!
  %call5 = invoke dereferenceable(140) %"class.std::basic_ostream"* @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(%"class.std::basic_ostream"* dereferenceable(140) %call3, i8 signext 10)
          to label %invoke.cont4 unwind label %lpad1
Block containing LandingPadInst must be jumped to only by the unwind edge of an invoke.
  %33 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
          cleanup
Block containing LandingPadInst must be jumped to only by the unwind edge of an invoke.
  %45 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
          cleanup
fatal error: error in backend: Broken function found, compilation aborted!
clang-3.5: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Obfuscator- clang version 3.5.0 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: i386-pc-linux-gnu
Thread model: posix
clang-3.5: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-3.5: note: diagnostic msg: 
********************

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

********************
Makefile:9: recipe for target 'stuff' failed
make: *** [stuff] Error 70

The C++ file contains only:

#include <iostream>

int main()
{
  try {
    std::cout << "Test\n";
  } catch (int e) {
    std::cout << e << '\n';
  }
}

I reduced the test case to this after originally being unable to compile a file which contains the declaration of an std::string.

I'm on commit baeacd7 from May 16th.

@pyknite pyknite self-assigned this Jun 19, 2015
@pyknite
Copy link
Collaborator

pyknite commented Jun 22, 2015

I can't reproduce the bug... This code compile fine on my machine. I tried on CentOS 7 and OS X.

@vominh2012
Copy link

I have crash too on Target: powerpc64-unknown-linux-gnu

Stack trace:
0 clang-3.5 0x0000000011158564 llvm::sys::PrintStackTrace(IO_FILE) + 4266585036
1 clang-3.5 0x00000000111587dc
2 clang-3.5 0x0000000011157f30
3 0x00000fff84aa0448 kernel_sigtramp_rt64 + 0
4 clang-3.5 0x0000000010758dac llvm::PPCInstPrinter::printBranchOperand(llvm::MCInst const
, unsigned int, llvm::raw_ostream&) + 4256427916
5 clang-3.5 0x0000000010759eac llvm::PPCInstPrinter::printInstruction(llvm::MCInst const
, llvm::raw_ostream&) + 4256432172
6 clang-3.5 0x000000001075a490 llvm::PPCInstPrinter::printInst(llvm::MCInst const_, llvm::raw_ostream&, llvm::StringRef) + 4256433656
7 clang-3.5 0x0000000010f53768
8 clang-3.5 0x00000000113d2064 llvm::AsmPrinter::EmitToStreamer(llvm::MCStreamer&, llvm::MCInst const&) + 4269085844
9 clang-3.5 0x00000000106d8034
10 clang-3.5 0x00000000113dc0bc llvm::AsmPrinter::EmitFunctionBody() + 4269125812
11 clang-3.5 0x000000001056fe90
12 clang-3.5 0x0000000010b8ab64 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 4260694580
13 clang-3.5 0x0000000010e08c14 llvm::FPPassManager::runOnFunction(llvm::Function&) + 4263221820
14 clang-3.5 0x0000000010e08d4c llvm::FPPassManager::runOnModule(llvm::Module&) + 4263222108
15 clang-3.5 0x0000000010e0bf30 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 4263234544
16 clang-3.5 0x0000000010e0c164 llvm::legacy::PassManager::run(llvm::Module&) + 4263235084
17 clang-3.5 0x00000000115c40d4 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module_, clang::BackendAction, llvm::raw_ostream_) + 4271077212
18 clang-3.5 0x00000000115bd95c
19 clang-3.5 0x0000000011a8ae60 clang::ParseAST(clang::Sema&, bool, bool) + 4275903088
20 clang-3.5 0x00000000112f9e1c clang::ASTFrontendAction::ExecuteAction() + 4268242884
21 clang-3.5 0x00000000115be9ac clang::CodeGenAction::ExecuteAction() + 4271056196
22 clang-3.5 0x00000000112faec0 clang::FrontendAction::Execute() + 4268246688
23 clang-3.5 0x00000000112d710c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 4268105292
24 clang-3.5 0x000000001138ade4 clang::ExecuteCompilerInvocation(clang::CompilerInstance_) + 4268813732
25 clang-3.5 0x00000000102c21d8 cc1_main(char const__, char const__, char const_, void*) + 4251743792
26 clang-3.5 0x00000000102c0498 main + 4251736400
27 libc.so.6 0x00000080bbccc088
28 libc.so.6 0x00000080bbccc280 __libc_start_main + 4293375408
Stack dump:
0. Program arguments: /usr/local/bin/clang-3.5 -cc1 -triple powerpc64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -main-file-name crash.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -target-cpu ppc64 -dwarf-column-info -resource-dir /usr/local/bin/../lib/clang/3.5.0 -internal-isystem /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7 -internal-isystem /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ppc64-redhat-linux -internal-isystem /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward -internal-isystem /usr/local/include -internal-isystem /usr/local/bin/../lib/clang/3.5.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/u0015999/iritech/llvm-obfuscator -ferror-limit 19 -fmessage-length 78 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -mllvm -bcf -o /tmp/crash-163ca9.s -x c++ crash.cpp

  1.  <eof> parser at end of file
    
  2.  Code generation
    
  3.  Running pass 'Function Pass Manager' on module 'crash.cpp'.
    
  4.  Running pass 'Linux PPC Assembly Printer' on function '@main'
    

clang-3.5: error: unable to execute command: Segmentation fault (core dumped)
clang-3.5: error: clang frontend command failed due to signal (use -v to see invocation)
Obfuscator- clang version 3.5.0 (tags/RELEASE_350/final) (based on LLVM 3.5.0svn)
Target: powerpc64-unknown-linux-gnu
Thread model: posix
clang-3.5: note: diagnostic msg: PLEASE submit a bug report to http://o-llvm.org and include the crash backtrace, preprocessed source, and associated run script.

@jeffcasavant
Copy link
Author

My environment is a 32-bit ArchLinux virtual installation.

[casavant@foreman ~]$ uname -a
Linux foreman 4.0.5-1-ARCH #1 SMP PREEMPT Sat Jun 6 18:52:28 CEST 2015 i686 GNU/Linux

@pyknite
Copy link
Collaborator

pyknite commented Jun 30, 2015

Please, can you try again with the new version?

@nickdiego
Copy link

I still can reproduce this issue (with both 3.6 and 4.0). After making some tests I realized that the issue doesn't occurs when optimization is disabled (-O0 flag).

Should I open a separate issue for this?
Any insights on how to fix this issue?

PS: I'm build O-LLVM using this tool I've implemented to streamline the build setup/process and tested targeting both my host Arch Linux x86_64 and using NDK build system:
https://github.com/nickdiego/docker-ollvm

@nickdiego
Copy link

Here's the exact output I'm getting:

#0 0x14fc442 llvm::sys::PrintStackTrace(_IO_FILE*) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x14fc442)
#1 0x14fa749 SignalHandler(int) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x14fa749)
#2 0x7fafd0850dd0 __restore_rt (/usr/lib/libpthread.so.0+0x11dd0)
#3 0x10546ff (anonymous namespace)::PeepholeOptimizer::findNextSource(unsigned int&, unsigned int&) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x10546ff)
#4 0x1055fc6 (anonymous namespace)::PeepholeOptimizer::runOnMachineFunction(llvm::MachineFunction&) [clone .part.220] (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x1055fc6)
#5 0x121c29f llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x121c29f)
#6 0x121e693 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x121e693)
#7 0x18bdbd3 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x18bdbd3)
#8 0x18abae0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x18abae0)
#9 0x1cb5265 clang::ParseAST(clang::Sema&, bool, bool) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x1cb5265)
#10 0x1674716 clang::FrontendAction::Execute() (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x1674716)
#11 0x1651db1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x1651db1)
#12 0x16ee683 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x16ee683)
#13 0x822108 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x822108)
#14 0x7fe262 main (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x7fe262)
#15 0x7fafcfbbef4a __libc_start_main (/usr/lib/libc.so.6+0x20f4a)
#16 0x820349 _start (/home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6+0x820349)
Stack dump:
0.	Program arguments: /home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/clang-3.6 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name hello-exceptions.cpp -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -momit-leaf-frame-pointer -dwarf-column-info -resource-dir /home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/../lib/clang/3.6.1 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/x86_64-pc-linux-gnu -internal-isystem /usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/local/include -internal-isystem /home/nick/devtools/android-ndk-r13b-ollvm3.6/toolchains/ollvm3.6/prebuilt/linux-x86_64/bin/../lib/clang/3.6.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdeprecated-macro -fdebug-compilation-dir /home/nick/projects/alcatel-pay/ndk-tests/hello-exceptions -ferror-limit 19 -fmessage-length 273 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops -vectorize-slp -mllvm -bcf -o /tmp/hello-exceptions-56dcf3.o -x c++ hello-exceptions.cpp 
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'hello-exceptions.cpp'.
4.	Running pass 'Peephole Optimizations' on function '@main'
clang-3.6: error: unable to execute command: Segmentation fault (core dumped)
clang-3.6: error: clang frontend command failed due to signal (use -v to see invocation)
Obfuscator-LLVM clang version 3.6.1 (tags/RELEASE_361/final) (based on Obfuscator-LLVM 3.6.1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang-3.6: note: diagnostic msg: PLEASE submit a bug report to http://o-llvm.org and include the crash backtrace, preprocessed source, and associated run script.
clang-3.6: note: diagnostic msg: 
********************

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

********************

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants