Project configuration:
Xcode 7.3.1
min iOS version 7.1
iOS SDK 9.3
cocoapods
While trying to compile mixed Objective-C/Swift project - getting error Segmentation Fault 11, with the next build log:
Compile *.swift
Command failed due to signal: Segmentation Fault 11
In details of, error I can see really long output with some useful info:
CompileSwift normal arm64 filePath/*.swift
0 swift 0x000000010b73266b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010b731956 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010b732ccf SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fff8b49e52a _sigtramp + 26
4 libsystem_platform.dylib 0x00007fa8f989d5e0 _sigtramp + 1849684176
5 swift 0x000000010994d737 swift::ClangImporter::Implementation::addEntryToLookupTable(clang::Sema&, swift::SwiftLookupTable&, clang::NamedDecl*) + 151
6 swift 0x000000010994d802 swift::ClangImporter::Implementation::addEntryToLookupTable(clang::Sema&, swift::SwiftLookupTable&, clang::NamedDecl*) + 354
7 swift 0x000000010994e44c swift::ClangImporter::Implementation::importHeader(swift::ModuleDecl*, llvm::StringRef, swift::SourceLoc, bool, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >) + 1468
8 swift 0x000000010994ebc6 swift::ClangImporter::importBridgingHeader(llvm::StringRef, swift::ModuleDecl*, swift::SourceLoc, bool) + 502
9 swift 0x000000010993ef2d swift::CompilerInstance::performSema() + 605
10 swift 0x0000000109482596 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 934
11 swift 0x000000010948168d frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
12 swift 0x000000010947d0ac main + 1932
13 libdyld.dylib 0x00007fff887b05ad start + 1
14 libdyld.dylib 0x000000000000026b start + 2005204159
And architecture compile error changes, if I switch from device to simulator and backwards, so shouldn't be architecture problem.
Reading Mac Console output I can see, crashes in SourceKit Service, at the same moment:
Thread 4 Crashed:: Dispatch queue: com.apple.root.default-qos
0 com.apple.SourceKitService.703.0.18.8 0x0000000106f1ca63 swift::ClangNode::getLocation() const + 19
1 com.apple.SourceKitService.703.0.18.8 0x0000000106c22a0f swift::ClangImporter::lookupBridgingHeaderDecls(llvm::function_ref<bool (swift::ClangNode)>, llvm::function_ref<void (swift::Decl*)>) const + 111
2 com.apple.SourceKitService.703.0.18.8 0x0000000106c22cb8 swift::ClangImporter::lookupDeclsFromHeader(llvm::StringRef, llvm::function_ref<bool (swift::ClangNode)>, llvm::function_ref<void (swift::Decl*)>) const + 216
3 com.apple.SourceKitService.703.0.18.8 0x00000001069a9034 swift::ide::printHeaderInterface(llvm::StringRef, swift::ASTContext&, swift::ASTPrinter&, swift::PrintOptions const&) + 852
4 com.apple.SourceKitService.703.0.18.8 0x00000001068bf368 SourceKit::SwiftInterfaceGenContext::create(llvm::StringRef, bool, llvm::StringRef, swift::CompilerInvocation, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 1992
5 com.apple.SourceKitService.703.0.18.8 0x00000001068c1de8 SourceKit::SwiftLangSupport::editorOpenHeaderInterface(SourceKit::EditorConsumer&, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<char const*>) + 1704
6 com.apple.SourceKitService.703.0.18.8 0x00000001068d7895 handleRequestImpl(void*, std::__1::function<void (void*)>) + 6773
7 com.apple.SourceKitService.703.0.18.8 0x00000001068d5dc4 sourcekitd::handleRequest(void*, std::__1::function<void (void*)>) + 420
Problem has occurred absolutely randomly project was always working fine, and at one point just stopped running on simulator, but continued running fine on device. After that it just stopped running anyway. Going back commit by commit, I can see, that this problem existed during the last couple of weeks, and checking every change it is quite a bit job and doesn't give any results.
Apparently it is some Xcode issue, but cleaning, removing derived data, module caches, Xcode settings, reinstalling Xcode, using beta version and previous version of Xcode, removing Source Kit Service, disabling/enabling modules support, bitcode, increasing/decreasing deployment target and any other suggestions, that can be googled - give the same result.
Reading internet comments - the problem should be in some part of the code, related with swift, but completely commenting or removing all swift related code gives another error:
cyclic dependency in module 'darwin'
And this way any of the frameworks like Foundation or UIKit, cannot be compiled, and I'm getting hundreds of errors, related to unknown classes.
Creating new project and adding files there one by one, didn't give any result as well - after adding all files and installing cocoapods, project has worked fine for some time, but after that - the same problem has started again.
So I see no way, how to find the exact part of code, which causes the problem (which really is Xcode bug, but there is almost no hope, that it will be fixed in Xcode 8, because it still exists in Beta version).
Will be glad to hear any help regarding this issue, I just can't sleep for a couple of days because of it :)
Found what has caused my issue:
I've had "Math.h" custom file and class in project, importing and using it caused an issue.
The strangest thing, that this file was in project during last 18 days, but everything worked fine. I guess, that it depends on how I'm using it, using it in Objective-C project, doesn't cause any issue.
Related
I am trying to symbolicate an iOS crash report. I am missing dSYMs for UIKitCore and other native libs.
The app is built with NativeScript. I have successfully symbolicated frames of my app and NativeScript framework. However I can't seem to find a way to symbolicate frames of libs like UIKitCore, they are still showing up as addresses. I have also tried searching for them using mdfind as per Apple documentation - they are not present on my Mac. I have also tried looking for these dSYMs online without luck.
Here is an excerpt of my crash log:
Last Exception Backtrace:
0 CoreFoundation 0x1cb5d927c 0x1cb4c1000 + 1147516
1 libobjc.A.dylib 0x1ca7b39f8 0x1ca7ae000 + 23032
2 NativeScript 0x10420fca0 NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool) + 277664 (JSErrors.mm:189)
3 NativeScript 0x104223354 NativeScript::FFICallback<NativeScript::ObjCBlockCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*) + 357204 (FFICallbackInlines.h:33)
4 NativeScript 0x104cb9894 ffi_closure_SYSV_inner + 11458708 (ffi.c:1218)
5 NativeScript 0x104cbc1b4 .Ldo_closure + 19
6 libdispatch.dylib 0x1cb018a38 0x1cafb9000 + 391736
7 libdispatch.dylib 0x1cb0197d4 0x1cafb9000 + 395220
8 libdispatch.dylib 0x1caff99e4 0x1cafb9000 + 264676
9 CoreFoundation 0x1cb56ac1c 0x1cb4c1000 + 695324
10 CoreFoundation 0x1cb565b54 0x1cb4c1000 + 674644
11 CoreFoundation 0x1cb5650b0 0x1cb4c1000 + 671920
12 GraphicsServices 0x1cd76579c 0x1cd75b000 + 42908
13 UIKitCore 0x1f7edf978 0x1f7623000 + 9161080
14 NativeScript 0x104cbc044 ffi_call_SYSV + 67
15 NativeScript 0x104cb8fb4 ffi_call_int + 11456436 (ffi.c:758)
16 NativeScript 0x104cb8ab0 ffi_call + 11455152 (ffi.c:767)
17 NativeScript 0x1041d4f90 NativeScript::FunctionWrapper::call(JSC::ExecState*) + 36752 (FunctionWrapper.mm:97)
18 NativeScript 0x104cb7b58 llint_entry + 32567
Many articles I found had examples with UIKitCore symbolicated so I assume this has to do with my configuration.
Part 1: Install the symbols
Check the full iOS version in the crash report. It should look like "iPhone OS 13.3 (17C54)"
There are a lot of repositories with iOS symbols or links to them. Like this one: https://github.com/Zuikyo/iOS-System-Symbols/blob/master/collected-symbol-files.md
Find and download symbols you need.
Unpack them to ~/Library/Developer/Xcode/iOS\ DeviceSupport
Add info.plist into the root folder if it missed (just copy from the other symbols and change its version value)
Part 2. Use the force of Xcode
Connect ANY real device, open Xcode, open the "Devices and Simulators" window, click the "View device logs" and then go to tab "All logs".
Drag and drop the crash into the table. Find it.
If the system symbols are not desymbolicated – do right-click on the crash and select "Re-symbolicate crash".
Repeat Step 3 multiple times (2-3 usually enough) – it needs time to resymbolicate it, but it looks like xcode does not update the crashlog automatically
And yes, UIKitCore is a system framework
UIKitCore is NOT an apple framework.
We have XCode 10.1 and XCode 10.2 on two different mac. The same project is debugging on mac devices and archiving from XCode 10.1. The project is in Swift 4.2. It also has Objective C files.
But it is not archiving from XCode version 10.2. ( It properly run in debug on devices )
Following is the error
CompileSwift normal arm64 (in target:
.....
..... warnings .....
.....
2. While running pass #13773 SILModuleTransform "LoadableByAddress".
0 swift 0x000000010e0a2ee3 PrintStackTraceSignalHandler(void*) + 51
1 swift 0x000000010e0a26bc SignalHandler(int) + 348
2 libsystem_platform.dylib 0x00007fff589b5b3d _sigtramp + 29
3 libsystem_platform.dylib 0x0000000000000008 _sigtramp + 2808390888
4 swift 0x000000010a139059 (anonymous namespace)::LoadableByAddress::runOnFunction(swift::SILFunction*) + 15961
5 swift 0x000000010a131a8b (anonymous namespace)::LoadableByAddress::run() + 75
6 swift 0x000000010acfa308 swift::SILPassManager::execute() + 7416
7 swift 0x000000010a0e451b runIRGenPreparePasses(swift::SILModule&, swift::irgen::IRGenModule&) + 1739
8 swift 0x000000010a0e2be0 swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::GlobalVariable**) + 1392
9 swift 0x0000000109f07030 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 49280
10 swift 0x0000000109ef76de swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
11 swift 0x0000000109e957be main + 1246
12 libdyld.dylib 0x00007fff587caed9 start + 1
13 libdyld.dylib 0x000000000000004b start + 2810401139
error: Segmentation fault: 11
Please let me have some clues to find the error.
Is it necessary to clear all the warnings ?
Regards
Sanjay
Update 1
Removed arm64 from Build Settings >> Architectures >> Valid Architectures
I Could build the Archive. ( I can not skip arm64, as it is compulsory for deployment )
But it means, one of my used library has issues in build of arm64. Need to find more. Problem could not be solved by XCode update 10.2.1
Update 2
Further searching found the answer at this link on stackoverflow.
the "solution" was to turn swift compiler code generation optimization level to -Onone in build settings for the release configuration.
This could not be a proper or correct solution, but at least for time being, this solution works.
I tried to archive my App and get this error:
Command failed due to signal: Segmentation fault: 11
When I Build it everything went fine, also on real devices. While archiving this happens. Any Ideas how to fix ?
This is a part of the error:
0 swift 0x000000010f79f3ad PrintStackTraceSignalHandler(void*) + 45
1 swift 0x000000010f79eb56 SignalHandler(int) + 790
2 libsystem_platform.dylib 0x00007fffc82d5bba _sigtramp + 26
3 libsystem_platform.dylib 0x0000000000000040 _sigtramp + 936551584
4 swift 0x000000010cae0de3 swift::CastOptimizer::optimizeUnconditionalCheckedCastAddrInst(swift::UnconditionalCheckedCastAddrInst*) + 1699
5 swift 0x000000010cb69d4d processFunction(swift::SILFunction&, bool, unsigned int) + 1917
6 swift 0x000000010cb70c9f (anonymous namespace)::ConstantPropagation::run() + 47
7 swift 0x000000010caff89e swift::SILPassManager::runOneIteration() + 5166
8 swift 0x000000010cb051f6 swift::runSILOptimizationPasses(swift::SILModule&) + 3462
9 swift 0x000000010c7ac0e2 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 20114
10 swift 0x000000010c7a52b3 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17859
11 swift 0x000000010c7615cf main + 8239
12 libdyld.dylib 0x00007fffc80c8255 start + 1
13 libdyld.dylib 0x00000000000000ee start + 938704538
And at the end:
1. While running pass #38147 SILFunctionTransform "Constant Propagation" on SILFunction "#_TTSg5VSC29UIApplicationLaunchOptionsKeyS_s8Hashable5UIKit_P__CSo8NSObjectS2_S0_10ObjectiveC_Ps9AnyObject____TFs17_dictionaryUpCastu2_Rxs8Hashable0_S_rFGVs10Dictionaryxq__GS0_q0_q1__".
Try disabling Swift Compiler Optimization for Release
Then if you get any errors for missing files:
In the file inspector of the file click on the folder icon next to "Location" and locate the file manually
In my case, I tested all solutions including disabling optimization in the build settings:
Build Settings > Optimization Level > Release > No optimization [-Onone]
I don't recommend the above solution since this will affect your entire app and your final binary won't be optimized.
Based on contact with technical team at Apple, There are multiple reasons that could lead to this error, however there's a known bug for archiving during optimization and you need to bypass it by finding the place that compiler is failing and add #_optimize(none) at the top of your function that's causing the issue.
This attribute will tell compiler to ignore the function for optimisation.
class MyNavigationController:UINavigationController {
#_optimize(none)
init(navigationController: UINavigationController?, context: AppContextProtocol) {
// content
}
}
Check Build Settings -> Swift 3 #Objc inference. It most likely should be off.
I am trying to analyse a crash log that a customer sent me, but I cannot get it to symbolicate the system library calls. It does symbolicate calls to my own methods correctly. That does not make it very practical to analyse what goes wrong.
I have run 'symbolicatecrash -v', to see what is causing the lack of symbolication. The likely cause is this:
## /Users/baraupp/Library/Developer/Xcode/iOS DeviceSupport/6.1.3 (10B329)/Symbols/usr/lib/system/libsystem_kernel.dylib doesn't contain armv7s slice
I have checked the mentioned libraries with 'lipo', which says that they contain 'armv7' but no 'armv7s'. After searching the web, it came out that this is a difference between iPhone 4 and iPhone 5. The normal solution seems to be to plug-in an iPhone 5 device and download the libraries from there. But I don't have an iPhone 5.
Anybody knows how to solve this?
To give you an idea how the symbolication looks like:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3bab0350 0x3ba9f000 + 70480
1 libsystem_c.dylib 0x3ba26fb2 0x3b9f8000 + 192434
2 libsystem_c.dylib 0x3ba63366 0x3b9f8000 + 439142
3 libc++abi.dylib 0x3b00bdda 0x3b008000 + 15834
4 libc++abi.dylib 0x3b009094 0x3b008000 + 4244
5 libobjc.A.dylib 0x3b5bca58 0x3b5b4000 + 35416
6 libc++abi.dylib 0x3b009118 0x3b008000 + 4376
7 libc++abi.dylib 0x3b0091b0 0x3b008000 + 4528
8 libc++abi.dylib 0x3b00a626 0x3b008000 + 9766
9 libobjc.A.dylib 0x3b5bc9b0 0x3b5b4000 + 35248
10 CoreFoundation 0x3380829c 0x337ff000 + 37532
11 CoreFoundation 0x338080c4 0x337ff000 + 37060
12 GraphicsServices 0x373e7336 0x373e2000 + 21302
13 UIKit 0x357242b4 0x356cd000 + 357044
14 Flyskyhy 0x000f8a66 main (main.m:17)
15 Flyskyhy 0x000f8a1c 0xf6000 + 10780
There are only two ways to solve this:
You either need an iPhone 5 device with iOS 6.1.3 to plug into your computer so Xcode can import the symbols
Or you need to get the symbols from another developer and replace yours with them.
Usually the symbols are part of the latest Xcode release, but Apple doesn't always provide Xcode updates when an iOS version only contains bug-fixes but no API changes.
I ran into this issue as well with an iOS7 app using XCode5, even though I had all the correct symbols.
What I found was that I had taken my dSYM file out of the archive where spotlight could index it, but the crashlog was only getting partically symbolicated (as seen in the question). But I had left the actual .app file in an xcarchive, and it was not able to be indexed by spotlight. As soon as I copied that file out of the archive to the visible location, I was able to symbolicate properly.
In following answer of Kerni:
You can install related Xcode with your target version of iOS and copy ~/Library/Developer/Xcode/iOS DeviceSupport/
My code is built with a base SDK of 5.1 and deployment of 4.0 and is built using ARC.
I've not experienced any problems previously when running it on a 4.3 test device, however its just crashed for the first time.
Any idea how to fix it?
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x00000001, 0xe7ffdefe
Crashed Thread: 0
Dyld Error Message:
Symbol not found: _objc_retainAutoreleasedReturnValue
Referenced from: /var/mobile/Applications/6AD37C1A-9642-4F0A-87E9-ED33EE45729D/Interactive Messages.app/Interactive Messages
Expected in: /usr/lib/libobjc.A.dylib
Dyld Version: 191.3
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 dyld 0x2fe01080 dyld_fatal_error + 0
1 dyld 0x2fe02a40 dyld::halt(char const*) + 48
2 dyld 0x2fe02b00 dyld::fastBindLazySymbol(ImageLoader**, unsigned long) + 172
3 libdyld.dylib 0x351d544e _dyld_fast_stub_entry(void*, long) + 30
4 libdyld.dylib 0x351d5374 dyld_stub_binder + 12
5 Interactive Messages 0x00036aee 0x1000 + 219886
6 libobjc.A.dylib 0x350af5d4 call_load_methods + 96
7 libobjc.A.dylib 0x350af446 load_images + 50
8 dyld 0x2fe03d7c _ZN4dyldL12notifySingleE17dyld_image_statesPK11ImageLoader + 64
9 dyld 0x2fe0a6a8 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&) + 236
10 dyld 0x2fe0aaaa ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 34
11 dyld 0x2fe020dc dyld::initializeMainExecutable() + 324
12 dyld 0x2fe06ffe dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**) + 1446
13 dyld 0x2fe01286 dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*) + 506
14 dyld 0x2fe01058 _dyld_start + 48
Where was the crash happening? I had the same thing suddenly start happening with the new compiler.
For me I had the code inside a +(void) load override which seemed to have been called before the arclite code was properly linked. I'm not sure this is possible, but moving the same code into +(void) initialize worked fine.
[This use to say 4.3 but I was wrong, all documentation says it iOS 4.]
EDIT: Grrr - I started my project a year ago, and wanted to use ARC and blocks. At that time I had some strong reason to use 4.3 not older releases, had to get permission from management, and it was all smooth sailing from then on. Now, I cannot determine why I did this. It's possible that at that time, the SDK was 4.3, and I made the assumption that is what I needed. I strongly recall I had a good reason to request 4.3 (I had just come back from WWDC) but now of course I cannot find anything to substantiate my answer. That said, the original poster seems to have given me the answer for this - so assume changing to 4.3 fixed his run time issue. If I ever find the reason I'll update this answer.
I agree with #Paul de Lange, and let me add some more note.
I am not 100% sure, but it seems runtime mechanism has been
slightly changed since Xcode 4.4, that ARC-enabled project will start linking libarclite_xxx.a (for iOS4) AFTER class's +(void)load is called (previously, it was BEFORE).
In more detail, method call goes like this in Xcode <= 4.3:
LINKING libarclite_xxx.a
class's +load
class category's +load
int main()
class's +initialize
and in Xcode >= 4.4:
class's +load
LINKING libarclite_xxx.a
class category's +load
int main()
class's +initialize
My app crashed on initial launch due to the addition of #autoreleasepool
directly in class's +load, and by moving its implementation to
either class's +initialize or class category's +load, everything went all fine.