[LLVMbugs] [Bug 10228] New: Crash on -dealloc in category with ARC enabled

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 30 07:28:39 PDT 2011


           Summary: Crash on -dealloc in category with ARC enabled
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: csdavec at swan.ac.uk
                CC: llvmbugs at cs.uiuc.edu

Compiling this file crashes clang:

@interface NSObject
    Class isa;
@interface Foo : NSObject @end

@implementation Foo (Private)
- (void) dealloc {}

This works when I target the NeXT runtime, but not when I target the GNU
runtime, but the crash appears to be in runtime-agnostic code, which is
confusing me.  This is the back trace:

#0  0x00007ffff45eb415 in raise (sig=<value optimized out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff45ee690 in abort () at abort.c:92
#2  0x00007ffff45e45c1 in __assert_fail (
    assertion=0x177e600 "isa<X>(Val) && \"cast<Ty>() argument of incompatible
type!\"", file=<value optimized out>, line=194, 
    function=0x177edc0 "typename llvm::cast_retty<To, From>::ret_type
llvm::cast(const Y&) [with X = clang::ObjCImplementationDecl, Y = const
clang::DeclContext*, typename llvm::cast_retty<To, From>::ret_type = const
    at assert.c:81
#3  0x0000000000d8da16 in llvm::cast<clang::ObjCImplementationDecl,
clang::DeclContext const*> (Val=@0x7fffffffb848)
    at /build/theraven/llvm/include/llvm/Support/Casting.h:194
#4  0x0000000000d807fd in (anonymous namespace)::FinishARCDealloc::Emit (
    this=0x7fffffffb970, CGF=..., isForEH=false) at CGObjC.cpp:224
#5  0x0000000000d092d4 in EmitCleanup (CGF=..., Fn=0x7fffffffb970, 
    ForEH=false, ActiveFlag=0x0) at CGCleanup.cpp:459
#6  0x0000000000d09e92 in clang::CodeGen::CodeGenFunction::PopCleanupBlock (
    this=0x7fffffffbd60, FallthroughIsBranchThrough=false) at CGCleanup.cpp:665
#7  0x0000000000d08e70 in clang::CodeGen::CodeGenFunction::PopCleanupBlocks (
    this=0x7fffffffbd60, Old=...) at CGCleanup.cpp:374
#8  0x0000000000e001e1 in clang::CodeGen::CodeGenFunction::FinishFunction (
    this=0x7fffffffbd60, EndLoc=...) at CodeGenFunction.cpp:150
#9  0x0000000000d812c9 in clang::CodeGen::CodeGenFunction::GenerateObjCMethod (
    this=0x7fffffffbd60, OMD=0x1fb48b0) at CGObjC.cpp:324
#10 0x0000000000cbd16c in clang::CodeGen::CodeGenModule::EmitTopLevelDecl (
    this=0x1fa60f0, D=0x1fb48b0) at CodeGenModule.cpp:2161
#11 0x0000000000cb1a83 in (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl (this=0x1f862b0, DG=...) at
#12 0x0000000000cb0eaa in clang::BackendConsumer::HandleTopLevelDecl (
    this=0x1f86120, D=...) at CodeGenAction.cpp:86
#13 0x0000000000e20b0f in clang::ParseAST (S=..., PrintStats=false)
    at ParseAST.cpp:85
#14 0x0000000000b7330d in clang::ASTFrontendAction::ExecuteAction (
    this=0x1f730d0) at FrontendAction.cpp:379
#15 0x0000000000cb051c in clang::CodeGenAction::ExecuteAction (this=0x1f730d0)
    at CodeGenAction.cpp:341
#16 0x0000000000b72f69 in clang::FrontendAction::Execute (this=0x1f730d0)
    at FrontendAction.cpp:299
#17 0x0000000000b58cd9 in clang::CompilerInstance::ExecuteAction (
    this=0x1f713a0, Act=...) at CompilerInstance.cpp:601
#18 0x0000000000aff3f3 in clang::ExecuteCompilerInvocation (Clang=0x1f713a0)
    at ExecuteCompilerInvocation.cpp:166
#19 0x0000000000af07d6 in cc1_main (ArgBegin=0x7fffffffce30, 
    Argv0=0x1f65338 "/build/theraven/llvm/Debug+Asserts/bin/clang", 

The problem is in frame #3 - it is trying to cast the -dealloc method's context
to a class implementation context, when it is actually a category
implementation context.  I'm not sure why this would work with the Mac

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list