llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

crash with weak alias attribute with same name with function

Open kkwli opened this issue 11 years ago • 5 comments

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(Val) && "cast() argument of incompatible type!"' failed. #​0 0x15db8828 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /gsa/tlbgsa-h1/00/kli/clang-latest/llvm/lib/Support/Unix/Signals.inc:431:0 #​1 0x15db8c84 PrintStackTraceSignalHandler(void*) /gsa/tlbgsa-h1/00/kli/clang-latest/llvm/lib/Support/Unix/Signals.inc:488:0 #​2 0x15db6fbc SignalHandler(int) /gsa/tlbgsa-h1/00/kli/clang-latest/llvm/lib/Support/Unix/Signals.inc:206:0 0 clang 0x0000000015db8828 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 92 1 clang 0x0000000015db8c84 2 clang 0x0000000015db6fbc 3 0x00003fff9f7f0478 __kernel_sigtramp_rt64 + 0 4 libc.so.6 0x00003fff9f3406b8 gsignal + 72 5 libc.so.6 0x00003fff9f34295c abort + 636 6 libc.so.6 0x00003fff9f336274 7 libc.so.6 0x00003fff9f336364 __assert_fail + 100 8 clang 0x00000000116e756c 9 clang 0x00000000116cff64 clang::CodeGen::CodeGenModule::checkAliases() + 264 10 clang 0x00000000116d06d0 clang::CodeGen::CodeGenModule::Release() + 84 11 clang 0x00000000115b363c 12 clang 0x000000001158310c 13 clang 0x0000000011a14914 clang::ParseAST(clang::Sema&, bool, bool) + 928 14 clang 0x0000000011094c80 clang::ASTFrontendAction::ExecuteAction() + 468 15 clang 0x00000000115867e0 clang::CodeGenAction::ExecuteAction() + 1472 16 clang 0x0000000011094544 clang::FrontendAction::Execute() + 200 17 clang 0x00000000110334c0 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1068 18 clang 0x0000000010fb8168 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1416 19 clang 0x0000000010f8f208 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 876 20 clang 0x0000000010fabe04 21 clang 0x0000000010fac5bc main + 1072 22 libc.so.6 0x00003fff9f324e80 23 libc.so.6 0x00003fff9f325074 __libc_start_main + 196 Stack dump: 0. Program arguments: /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

  1.  <eof> parser at end of file
    
  2.  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:


kkwli avatar May 13 '15 03:05 kkwli

mentioned in issue llvm/llvm-bugzilla-archive#25397

DimitryAndric avatar Nov 26 '21 21:11 DimitryAndric

*** Bug llvm/llvm-bugzilla-archive#25397 has been marked as a duplicate of this bug. ***

DimitryAndric avatar Nov 05 '15 01:11 DimitryAndric

r246882.

hfinkel avatar Sep 04 '15 23:09 hfinkel

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(GD.getDecl()); 282 const AliasAttr *AA = D->getAttr(); 283 StringRef MangledName = getMangledName(GD); 284 llvm::GlobalValue *Entry = GetGlobalValue(MangledName); 285 auto *Alias = castllvm::GlobalAlias(Entry); 286 const llvm::GlobalValue *GV = getAliasedGlobal(*Alias);

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).

hfinkel avatar Sep 04 '15 19:09 hfinkel

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

llvmbot avatar May 23 '15 04:05 llvmbot