Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang crashes when using __attribute__((alias(""))) #6516

Open Quuxplusone opened 14 years ago

Quuxplusone commented 14 years ago
Bugzilla Link PR8588
Status NEW
Importance P normal
Reported by Jonathan Schleifer (js-llvm-bugzilla@webkeks.org)
Reported on 2010-11-11 13:37:18 -0800
Last modified on 2010-11-18 19:45:02 -0800
Version trunk
Hardware Macintosh MacOS X
CC clattner@nondot.org, fjahanian@apple.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
avalon:/tmp$ cat test.m
extern void *foo __attribute__((alias("OBJC_CLASS_$_Foo")));

@interface Foo
@end

@implementation Foo
@end

avalon:/tmp$ clang -c test.m
Assertion failed: (C->getType() == T->getElementType(I-V.begin()) &&
"Initializer for struct element doesn't match struct element type!"), function
ConstantStruct, file Constants.cpp, line 555.
0  clang             0x0000000101404ae2 std::vector<llvm::sys::Path,
std::allocator<llvm::sys::Path>
>::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::sys::Path*,
std::vector<llvm::sys::Path, std::allocator<llvm::sys::Path> > >,
llvm::sys::Path const&) + 11746
1  clang             0x0000000101405933 std::vector<llvm::sys::Path,
std::allocator<llvm::sys::Path>
>::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::sys::Path*,
std::vector<llvm::sys::Path, std::allocator<llvm::sys::Path> > >,
llvm::sys::Path const&) + 15411
2  libSystem.B.dylib 0x00007fff8782c67a _sigtramp + 26
3  libSystem.B.dylib 0x0000000000000038 _sigtramp + 2021472728
4  clang             0x0000000100017862
std::vector<llvm::PassRegistrationListener*,
std::allocator<llvm::PassRegistrationListener*>
>::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::PassRegistrationListener**,
std::vector<llvm::PassRegistrationListener*,
std::allocator<llvm::PassRegistrationListener*> > >,
llvm::PassRegistrationListener* const&) + 4274
5  clang             0x00000001012840c0 llvm::cast_retty<llvm::StructType,
llvm::CompositeType const*>::ret_type llvm::cast<llvm::StructType,
llvm::CompositeType const*>(llvm::CompositeType const* const&) + 14720
6  clang             0x000000010129d89e
llvm::ConstantUniqueMap<std::vector<llvm::Constant*,
std::allocator<llvm::Constant*> >, llvm::StructType, llvm::ConstantStruct,
true>::Create(llvm::StructType const*, std::vector<llvm::Constant*,
std::allocator<llvm::Constant*> > const&,
std::_Rb_tree_iterator<std::pair<std::pair<llvm::StructType const*,
std::vector<llvm::Constant*, std::allocator<llvm::Constant*> > > const,
llvm::ConstantStruct*> >) + 78
7  clang             0x00000001012896ce llvm::cast_retty<llvm::StructType,
llvm::CompositeType const*>::ret_type llvm::cast<llvm::StructType,
llvm::CompositeType const*>(llvm::CompositeType const* const&) + 36750
8  clang             0x0000000100242b34 llvm::IRBuilder<true,
llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true>
>::CreateStructGEP(llvm::Value*, unsigned int, llvm::Twine const&) + 70484
9  clang             0x0000000100257878 llvm::IRBuilder<true,
llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true>
>::CreateStructGEP(llvm::Value*, unsigned int, llvm::Twine const&) + 155800
10 clang             0x00000001002a4076 llvm::DenseMap<clang::Expr const*,
llvm::Value*, llvm::DenseMapInfo<clang::Expr const*>,
llvm::DenseMapInfo<llvm::Value*> >::grow(unsigned int) + 46182
11 clang             0x00000001002c62cc
llvm::SmallVectorTemplateBase<llvm::APInt, false>::grow(unsigned long) + 1468
12 clang             0x000000010028d98b
clang::ASTRecordLayout::getVBaseClassOffsetInBits(clang::CXXRecordDecl const*)
const + 2043
13 clang             0x00000001002d24e6 llvm::GetElementPtrInst*
llvm::GetElementPtrInst::CreateInBounds<llvm::Value**>(llvm::Value*,
llvm::Value**, llvm::Value**, llvm::Twine const&, llvm::Instruction*) + 710
14 clang             0x000000010028e20c
clang::ASTRecordLayout::getVBaseClassOffsetInBits(clang::CXXRecordDecl const*)
const + 4220
15 clang             0x000000010004e319 llvm::DenseMap<clang::IdentifierInfo
const*, unsigned int, llvm::DenseMapInfo<clang::IdentifierInfo const*>,
llvm::DenseMapInfo<unsigned int> >::grow(unsigned int) + 7849
16 clang             0x000000010002114e llvm::raw_ostream::operator<<(char
const*) + 1742
17 clang             0x0000000100019175
std::vector<llvm::PassRegistrationListener*,
std::allocator<llvm::PassRegistrationListener*>
>::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::PassRegistrationListener**,
std::vector<llvm::PassRegistrationListener*,
std::allocator<llvm::PassRegistrationListener*> > >,
llvm::PassRegistrationListener* const&) + 10693
18 clang             0x00000001000200d4 std::vector<std::string,
std::allocator<std::string> >::operator=(std::vector<std::string,
std::allocator<std::string> > const&) + 11604
19 clang             0x0000000100017b38
std::vector<llvm::PassRegistrationListener*,
std::allocator<llvm::PassRegistrationListener*>
>::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::PassRegistrationListener**,
std::vector<llvm::PassRegistrationListener*,
std::allocator<llvm::PassRegistrationListener*> > >,
llvm::PassRegistrationListener* const&) + 5000
Stack dump:
0.  Program arguments: /usr/local/bin/clang -cc1 -triple x86_64-apple-
darwin10.0.0 -emit-obj -mrelax-all -disable-free -main-file-name test.m -pic-
level 1 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -
target-linker-version 97.14 -resource-dir /usr/local/bin/../lib/clang/2.9 -
ferror-limit 19 -fmessage-length 80 -stack-protector 1 -fblocks -fexceptions -
fobjc-nonfragile-abi2 -fobjc-dispatch-method=mixed -fdiagnostics-show-option -
fcolor-diagnostics -o test.o -x objective-c test.m
1.  <eof> parser at end of file
2.  test.m:6:1: LLVM IR generation of declaration 'Foo'
clang: error: unable to execute command: Illegal instruction
clang: error: clang frontend command failed due to signal 1 (use -v to see
invocation)
Quuxplusone commented 13 years ago

Yes, the objc backend isn't careful enough when it creates names for IR. That said, I don't think that this is very important, whatever you're trying to do is almost certainly a bad idea :-)

Quuxplusone commented 13 years ago

Yes, I agree, I am doing something bad, but Apple's Blocks ABI forces me to because it needs the symbols _NSConcreteStackBlock etc. exported and pointing to these classes, since someone decided not to look up the classes at runtime using a constructor, like it should be, or at least do it similar to @"" string literals.

For now, I fixed it using a -Wl,-alias_list instead of relying on Clang. But this does not fix the bug in Clang, as it worked before with Clang.