obfuscator-llvm / obfuscator

3.93k stars 1.18k forks source link

-bcf crashes when compiling Obj-C project #73

Open Dendim0n opened 7 years ago

Dendim0n commented 7 years ago

TestFile: main.m:

#import <Foundation/Foundation.h>
#import "TestClass.h"

int main() {
    @autoreleasepool {
        // insert code here...
        NSLog(@"Hello, World!");
        TestClass *tst = [[TestClass alloc] init];
    }
    return 0;
}

TestClass.h:

#import <Foundation/Foundation.h>

@interface TestClass : NSObject

@end

TestClass.m:

#import "TestClass.h"

@implementation TestClass

-(instancetype)init {
    self = [super init];
    [self testMethod];
    return self;
}
-(void)testMethod {
    NSLog(@"test");
}

@end

Crashlog:

mismatched subprogram between llvm.dbg.declare variable and !dbg attachment
  call void @llvm.dbg.declare(metadata %0** %self.addralteredBB, metadata !71, metadata !49), !dbg !67
label %originalBBalteredBB
void (%0*, i8*)* @"\01-[TestClass testMethod]"
!71 = !DILocalVariable(name: "self", arg: 1, scope: !72, type: !66, flags: DIFlagArtificial | DIFlagObjectPointer)
!72 = distinct !DISubprogram(name: "-[TestClass testMethod]", scope: !1, file: !1, line: 18, type: !62, isLocal: true, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !73, variables: !2)
!67 = !DILocation(line: 0, scope: !61)
!61 = distinct !DISubprogram(name: "-[TestClass testMethod]", scope: !1, file: !1, line: 18, type: !62, isLocal: true, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
mismatched subprogram between llvm.dbg.declare variable and !dbg attachment
  call void @llvm.dbg.declare(metadata i8** %_cmd.addralteredBB, metadata !76, metadata !49), !dbg !67
label %originalBBalteredBB
void (%0*, i8*)* @"\01-[TestClass testMethod]"
!76 = !DILocalVariable(name: "_cmd", arg: 2, scope: !72, type: !52, flags: DIFlagArtificial)
!72 = distinct !DISubprogram(name: "-[TestClass testMethod]", scope: !1, file: !1, line: 18, type: !62, isLocal: true, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !73, variables: !2)
!67 = !DILocation(line: 0, scope: !61)
!61 = distinct !DISubprogram(name: "-[TestClass testMethod]", scope: !1, file: !1, line: 18, type: !62, isLocal: true, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
mismatched subprogram between llvm.dbg.declare variable and !dbg attachment
  call void @llvm.dbg.declare(metadata %0** %self.addralteredBB, metadata !71, metadata !49), !dbg !67
label %originalBBalteredBB
void (%0*, i8*)* @"\01-[TestClass testMethod]"
!71 = !DILocalVariable(name: "self", arg: 1, scope: !72, type: !66, flags: DIFlagArtificial | DIFlagObjectPointer)
!72 = distinct !DISubprogram(name: "-[TestClass testMethod]", scope: !1, file: !1, line: 18, type: !62, isLocal: true, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !73, variables: !2)
!67 = !DILocation(line: 0, scope: !61)
!61 = distinct !DISubprogram(name: "-[TestClass testMethod]", scope: !1, file: !1, line: 18, type: !62, isLocal: true, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
mismatched subprogram between llvm.dbg.declare variable and !dbg attachment
  call void @llvm.dbg.declare(metadata i8** %_cmd.addralteredBB, metadata !76, metadata !49), !dbg !67
label %originalBBalteredBB
void (%0*, i8*)* @"\01-[TestClass testMethod]"
!76 = !DILocalVariable(name: "_cmd", arg: 2, scope: !72, type: !52, flags: DIFlagArtificial)
!72 = distinct !DISubprogram(name: "-[TestClass testMethod]", scope: !1, file: !1, line: 18, type: !62, isLocal: true, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !73, variables: !2)
!67 = !DILocation(line: 0, scope: !61)
!61 = distinct !DISubprogram(name: "-[TestClass testMethod]", scope: !1, file: !1, line: 18, type: !62, isLocal: true, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
Assertion failed: (DI->getVariable()->isValidLocationForIntrinsic(DbgLoc) && "Expected inlined-at fields to agree"), function selectIntrinsicCall, file /lib/CodeGen/SelectionDAG/FastISel.cpp, line 1145.
xelzmm commented 7 years ago

It's seems that debug info was incorrectly cloned while createAlteredBasicBlock try compile the source with out debug info (in release mode) as workaround

Dendim0n commented 7 years ago

@xelzmm I'll try it, thx.