crash with weak alias attribute with same name with function
| Bugzilla Link | 23509 |
| Resolution | FIXED |
| Resolved on | Nov 04, 2015 17:05 |
| Version | trunk |
| OS | Linux |
| CC | @hfinkel |
Extended Description
$ cat d1a.c int foo();
int foo() attribute((weak,alias("foo")));
$ clang -v d1a.c
clang version 3.7.0 (http://llvm.org/git/clang.git 990bb3c80c90fa29797082baf72d1a67817fd1eb) (http://llvm.org/git/llvm.git d3a9dd70429239093b136e178147ec0425dab269)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9.1
Selected GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/home/kli/wrk/dtmp-clang/builds/Debug+Asserts/bin/clang" -cc1 -triple powerpc64le-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name d1a.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu ppc64le -target-abi elfv2 -target-linker-version 2.24.90.20141014 -v -dwarf-column-info -fno-unique-section-names -resource-dir /home/kli/wrk/dtmp-clang/builds/Debug+Asserts/bin/../lib/clang/3.7.0 -internal-isystem /usr/local/include -internal-isystem /home/kli/wrk/dtmp-clang/builds/Debug+Asserts/bin/../lib/clang/3.7.0/include -internal-externc-isystem /usr/include/powerpc64le-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/kli/wrk -ferror-limit 19 -fmessage-length 80 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/d1a-00eef8.o -x c d1a.c
clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target powerpc64le-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/home/kli/wrk/dtmp-clang/builds/Debug+Asserts/bin/../lib/clang/3.7.0/include
/usr/include/powerpc64le-linux-gnu
/usr/include
End of search list.
clang: /gsa/tlbgsa-h1/00/kli/clang-latest/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::GlobalAlias; Y = llvm::GlobalValue; typename llvm::cast_retty<X, Y*>::ret_type = llvm::GlobalAlias*]: Assertion `isa
-
<eof> parser at end of file -
Per-file LLVM IR generation
clang: error: unable to execute command: Aborted clang: error: clang frontend command failed due to signal (use -v to see invocation) clang version 3.7.0 (http://llvm.org/git/clang.git 990bb3c80c90fa29797082baf72d1a67817fd1eb) (http://llvm.org/git/llvm.git d3a9dd70429239093b136e178147ec0425dab269) Target: powerpc64le-unknown-linux-gnu Thread model: posix clang: 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: 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/d1a-85e08a.c clang: note: diagnostic msg: /tmp/d1a-85e08a.sh clang: note: diagnostic msg:
mentioned in issue llvm/llvm-bugzilla-archive#25397
*** Bug llvm/llvm-bugzilla-archive#25397 has been marked as a duplicate of this bug. ***
r246882.
I just ran across this too, the following still crashes on trunk:
int test(void) attribute((weak,alias("test")));
The problem is this code:
280 for (const GlobalDecl &GD : Aliases) {
281 const auto *D = cast
which crashes in the castllvm::GlobalAlias(Entry) because, in this case, Entry is really:
declare extern_weak signext i32 @test() #0
(which is a GlobalVariable, but not a GlobalAlias).
This crashes with just "clang -cc1 -emit-llvm test.c".
#8 0x1cae7c9 llvm::cast_retty<llvm::GlobalAlias, llvm::GlobalValue*>::ret_type llvm::cast<llvm::GlobalAlias, llvm::GlobalValue>(llvm::GlobalValue*) /home/espindola/llvm/llvm/include/llvm/Support/Casting.h:237:3 #9 0x28f2829 clang::CodeGen::CodeGenModule::checkAliases() /home/espindola/llvm/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp:271:11 #10 0x28f33f7 clang::CodeGen::CodeGenModule::Release() /home/espindola/llvm/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp:347:3 #11 0x284062c (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) /home/espindola/llvm/llvm/tools/clang/lib/CodeGen/ModuleBuilder.cpp:206:5 #12 0x28258e1 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /home/espindola/llvm/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:135:9 #13 0x352d284 clang::ParseAST(clang::Sema&, bool, bool) /home/espindola/llvm/llvm/tools/clang/lib/Parse/ParseAST.cpp:151:3 #14 0x23ced19 clang::ASTFrontendAction::ExecuteAction() /home/espindola/llvm/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:538:1 #15 0x28247a8 clang::CodeGenAction::ExecuteAction() /home/espindola/llvm/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:741:1 #16 0x23ce800 clang::FrontendAction::Execute() /home/espindola/llvm/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:443:7 #17 0x23881cb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/espindola/llvm/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:815:7 #18 0x2524a98 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/espindola/llvm/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:222:8 #19 0xa73a07 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/espindola/llvm/llvm/tools/clang/tools/driver/cc1_main.cpp:110:11 #20 0xa68b93 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /home/espindola/llvm/llvm/tools/clang/tools/driver/driver.cpp:369:5 #21 0xa6821b main /home/espindola/llvm/llvm/tools/clang/tools/driver/driver.cpp:415:5