Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obfuscator-llvm 3.5 crashes when building a specific m file #14

Closed
MasterBeta opened this issue Nov 5, 2014 · 9 comments
Closed

obfuscator-llvm 3.5 crashes when building a specific m file #14

MasterBeta opened this issue Nov 5, 2014 · 9 comments
Assignees

Comments

@MasterBeta
Copy link

os: OS X 10.10.1 (14B17)
Xcode:5.1.1
bfuscator-llvm version: commit 3bc5428, branch llvm_3.5

BackTrace:

/Users/SomeUser/llvm_obfuscator/build/bin/clang -x objective-c -arch armv7s -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -Wno-trigraphs -fpascal-strings -Os -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wno-bool-conversion -Wenum-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -isysroot /Applications/Xcode-5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -Wno-sign-conversion -iquote /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/SomeSDK-generated-files.hmap -I/Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/SomeSDK-own-target-headers.hmap -I/Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/SomeSDK-all-target-headers.hmap -iquote /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/SomeSDK-project-headers.hmap -I/Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Products/Release-iphoneos/include -I/Applications/Xcode-5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/DerivedSources/armv7s -I/Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/DerivedSources -F/Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Products/Release-iphoneos -miphoneos-version-min=4.3 -mllvm -sub -mllvm -bcf -mllvm -fla -include /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/PrecompiledHeaders/SomeSDK-Prefix-cjjuroblszylmgbipghgksrtnqty/SomeSDK-Prefix.pch -c /Users/SomeUser/Documents/SomeSDK/source/Adapter/iOS/CMethodBridge/SomeFile.m -o /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/Objects-normal/armv7s/SomeFile.o

0 clang-3.5 0x0000000104809bd8 llvm::sys::PrintStackTrace(sFILE) + 40
1 clang-3.5 0x000000010480a0b4 SignalHandler(int) + 452
2 libsystem_platform.dylib 0x00007fff8d861f1a sigtramp + 26
3 libsystem_platform.dylib 0x00007faa0854a2a0 sigtramp + 2060354464
4 clang-3.5 0x0000000104556c2f llvm::FPPassManager::doInitialization(llvm::Module&) + 63
5 clang-3.5 0x0000000104556fa0 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 736
6 clang-3.5 0x0000000104be743e clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module
, clang::BackendAction, llvm::raw_ostream
) + 6318
7 clang-3.5 0x0000000104cfdbfb clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 523
8 clang-3.5 0x0000000104fd86f4 clang::ParseAST(clang::Sema&, bool, bool) + 468
9 clang-3.5 0x0000000104cfc677 clang::CodeGenAction::ExecuteAction() + 87
10 clang-3.5 0x00000001049e773e clang::FrontendAction::Execute() + 62
11 clang-3.5 0x00000001049bb5c3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 867
12 clang-3.5 0x0000000104a1d0f2 clang::ExecuteCompilerInvocation(clang::CompilerInstance
) + 4354
13 clang-3.5 0x0000000103c91abc cc1_main(char const**, char const**, char const_, void_) + 1036
14 clang-3.5 0x0000000103c8e7b8 main + 1128
15 libdyld.dylib 0x00007fff927ac5c9 start + 1
Stack dump:
0. Program arguments: /Users/SomeUser/llvm_obfuscator/build/bin/clang-3.5 -cc1 -triple thumbv7s-apple-ios4.3.0 -emit-obj -disable-free -disable-llvm-verifier -main-file-name SomeFile.m -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -target-cpu swift -target-feature +soft-float-abi -target-abi apcs-gnu -mfloat-abi soft -dwarf-column-info -coverage-file /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/Objects-normal/armv7s/SomeFile.o -resource-dir /Users/SomeUser/llvm_obfuscator/build/bin/../lib/clang/3.5.0 -isysroot /Applications/Xcode-5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -iquote /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/SomeSDK-generated-files.hmap -iquote /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/SomeSDK-project-headers.hmap -include-pch /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/PrecompiledHeaders/SomeSDK-Prefix-cjjuroblszylmgbipghgksrtnqty/SomeSDK-Prefix.pch.pch -I /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/SomeSDK-own-target-headers.hmap -I /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/SomeSDK-all-target-headers.hmap -I /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Products/Release-iphoneos/include -I /Applications/Xcode-5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/DerivedSources/armv7s -I /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/DerivedSources -F/Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Products/Release-iphoneos -Os -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wno-bool-conversion -Wenum-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -Wprotocol -Wdeprecated-declarations -Wno-sign-conversion -std=gnu99 -fdebug-compilation-dir /Users/SomeUser/Documents/SomeSDK/source/SDK/iOS/SomeSDK -ferror-limit 19 -fmacro-backtrace-limit 0 -fmessage-length 0 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=ios-4.3.0 -fencode-extended-block-signature -fobjc-exceptions -fexceptions -fsjlj-exceptions -fpascal-strings -fdiagnostics-show-option -fdiagnostics-show-note-include-stack -vectorize-loops -vectorize-slp -mllvm -sub -mllvm -bcf -mllvm -fla -o /Users/SomeUser/Documents/SomeSDK/target/ios/sdk/Build/Intermediates/SomeSDK.build/Release-iphoneos/SomeSDK.build/Objects-normal/armv7s/SomeFile.o -x objective-c /Users/SomeUser/Documents/SomeSDK/source/Adapter/iOS/CMethodBridge/SomeFile.m

  1.  <eof> parser at end of file 
    
  2.  Code generation
    

clang-3.5: error: unable to execute command: Segmentation fault: 11
clang-3.5: error: clang frontend command failed due to signal (use -v to see invocation)
Obfuscator- clang version 3.5.0 (tags/RELEASE_350/final) (based on LLVM 3.5.0svn)
Target: arm-apple-darwin14.0.0
Thread model: posix

Description: obfucator-llvm crashes every time when building SomeFile.m. C and OC code are mixed it SomFile.m.

@pyknite pyknite self-assigned this Nov 5, 2014
@pyknite
Copy link
Collaborator

pyknite commented Nov 5, 2014

Hi,

I can't reproduce your problem... I assume, seeing your backtrace, that you are trying to compile a program for IOS?

I tried to compile a IOS application within Xcode with Obfuscator and It worked fine.

Can you give me more information please?

Cheers

@MasterBeta
Copy link
Author

I wrote a demo to find out the procedure to reproduce the problem.

The demo contains a m file with a bunch of functions like this:

char* getCurrentDeviceNameBridge()
{
return transNSStringToCString([[UIDevice currentDevice] name]);
}

The compiler is set to "Obfuscator 3.5", which was installed by following the offical OLLVM install instruction.

Also i add some flags to the "Other C Flags" section in build setting:

"-mllvm, "-sub", "-mllvm", "-bcf", "-mllvm", "-fla", "-miphoneos-version-min=6.0"

The demo's building process crashed sometimes, with the same kind of backtrace i provided yesterday.

But everything works fine when i switch the compiler back to Obfuscator 3.4.

@MasterBeta
Copy link
Author

I can provide the files follows or the Demo Project if necessary:

clang-3.5: note: diagnostic msg: /var/folders/18/xxx/T/CrashedCode-871862.m
clang-3.5: note: diagnostic msg: /var/folders/18/xxx/T/CrashedCode-871862.cache
clang-3.5: note: diagnostic msg: /var/folders/18/xxx/T/CrashedCode-871862.sh

@MasterBeta MasterBeta changed the title lobfuscator-llvm 3.5 crashes when building a specific .m file obfuscator-llvm 3.5 crashes when building a specific m file Nov 6, 2014
@MasterBeta
Copy link
Author

By removing code function by function, i've found the function caused the crash:

@interface DummyLocker : NSObject
@end

@implementation DummyLocker
@end

int functionA(signed long long v) {
    @synchronized([DummyLocker class]){
         //do someting
         return 1;
    }
    return 0;
}

signed long long  functionB(signed long long  v){
    //do something
    return v;
}

signed long long  functionC(signed long long  v){
    @synchronized([DummyLocker class]){
        return functionB(v);
    }
}

If i remove the codes above or replace @synchronied with NSLock, the crash doesn't reproduce anymore.

Hope this helps :)

@pyknite
Copy link
Collaborator

pyknite commented Nov 7, 2014

Thx for details... Unfortunately I won't be able to check that until next friday.

@MasterBeta
Copy link
Author

Other than modifying my code, both adding "attribute((__annotate(("nobcf"))))" flag and removing "-bcf" can make the crash disappear.

Hope this helps :)

@pyknite
Copy link
Collaborator

pyknite commented Nov 21, 2014

Working on it... I'll probably have a fix by monday!

@pyknite
Copy link
Collaborator

pyknite commented Dec 3, 2014

Sorry, I didn't had the time to work properly on it... A fix will come soon!

@pyknite
Copy link
Collaborator

pyknite commented Dec 4, 2014

Just pushed some changes...

Can you try to update your local repo and tell me if it works?

I created a new IOS project in Xcode, pasted you code in the main.m file and added a simple loop with a NSLog inside where you put the "// Do something" comments.

I tried the code, with all flags and once with only bcf (both time with -mllvm -bogus-cf=100, means every basic block is obfuscated) and everything went fine (compil+exec).

Thx for your feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants