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.
Related
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 transfer swift 4 to swift 4.2 with XCode 10.0 release
then got this msg:
*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
could not find 'init(frame:)' in parent class
0 swift 0x00000001050f864a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x00000001050f7dfe SignalHandler(int) + 302
2 libsystem_platform.dylib 0x00007fff77964b3d _sigtramp + 29
3 libsystem_platform.dylib 0x00007ffeee8fb4e0 _sigtramp + 1996057024
4 libsystem_c.dylib 0x00007fff778231c9 abort + 127
5 swift 0x000000010255e0fb swift::ModuleFile::fatal(llvm::Error) + 1915
6 swift 0x0000000102595753 getSILDeclRef(swift::ModuleFile*, llvm::ArrayRef<unsigned long long>, unsigned int&) + 307
7 swift 0x0000000102597a94 swift::SILDeserializer::readVTable(llvm::PointerEmbeddedInt<unsigned int, 31>) + 740
8 swift 0x000000010263e84b swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 331
9 swift 0x00000001013889be performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 34558
10 swift 0x000000010137cdc5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
11 swift 0x0000000101322a35 main + 1349
12 libdyld.dylib 0x00007fff7777b085 start + 1
and this in the end:
1. While deserializing SIL vtable for 'MenuNavTitleView' in module 'projectName'
error: Abort trap: 6
I looked for some reasons such as .zero, then even I replaced all .zero in my code, it still have this problem.
Does someone know how to fix this fatal error?
I was facing the same problem in Xcode 10.2.1.
After days trying to solve it, I discovered that in my case this error was caused by a Swift class that inherits an Objective-C Third Party class (more specifically the FSCalendarCell class from https://github.com/WenchaoD/FSCalendar).
I rewrote the Swift class for Objective-C and it compiled and ran without any issues.
I have a finished project with about 30vcs, Firebase, Googlemaps integration, etc - ie a really big complicated project, it is a geolocation based game that I've finally finished after several months of work.
Worked and compiled just fine, until I tried to compile it in the new Swift 3.1/ Xcode 8.3.
After changing the recommended syntax on a few lines to clear the new XCODE 8.3 errors, compiling fails with "Abort Trap: 6" error.
This is the last few lines of the debugger (prior to that theres about 100 lines of incomprehensible file names/numbers etc).
0 swift 0x00000001089f1eb7
PrintStackTraceSignalHandler(void*) + 39 1 swift
0x00000001089f1366 SignalHandler(int) + 646 2
libsystem_platform.dylib 0x00007fffc602eb3a _sigtramp + 26 3
libsystem_platform.dylib 0x0000000100000001 _sigtramp + 972887265 4
libsystem_c.dylib 0x00007fffc5eb3420 abort + 129 5 swift
0x0000000106454644
swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt,
llvm::Optional) + 38404 6 swift
0x00000001064564fa
swift::ModuleFile::getType(llvm::PointerEmbeddedInt)
+ 2106 7 swift 0x000000010644f373 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt,
llvm::Optional) + 17203 8 swift
0x0000000106459f24
swift::ModuleFile::maybeReadPattern(swift::DeclContext*) + 740 9
swift 0x000000010644f605
swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt,
llvm::Optional) + 17861 10 swift
0x00000001064607c8 swift::ModuleFile::loadAllMembers(swift::Decl*,
unsigned long long) + 600 11 swift
0x0000000106840f0d swift::NominalTypeDecl::getMembers() const + 125 12
swift 0x0000000106828c75 (anonymous
namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) +
869 13 swift 0x0000000106826645 (anonymous
namespace)::Traversal::doIt(swift::Decl*) + 277 14 swift
0x000000010619a75f
swift::SILPassManager::SILPassManager(swift::SILModule*,
llvm::StringRef) + 1471 15 swift 0x00000001061a135f
swift::runSILDiagnosticPasses(swift::SILModule&) + 159 16 swift
0x0000000105811282 swift::performFrontend(llvm::ArrayRef,
char const*, void*, swift::FrontendObserver*) + 42866 17 swift
0x00000001057c088c main + 9052 18 libdyld.dylib
0x00007fffc5e1f235 start + 1 Stack dump:
(here is about 150 lines of incomprehensible debugging numbers/files/alphanumericals - followed by this in the end):
While loading members for 'homePage' in module 'googleMapsPractice'
While deserializing PatternBindingDecl #295in 'googleMapsPractice'
While deserializing 'gameDBRef' (VarDecl #296)in 'googleMapsPractice'
While deserializing decl #1009 (XREF)in 'googleMapsPractice'
Cross-reference to module 'FirebaseDatabase' ... FIRDatabaseReference
I am really stuck as I don't know where to look to debug this.
'homePage.swift' is the set-up page VC of the game, and is the only VC referenced in the debugger, is there any common solutions to Abort Trap 6 errors that I could try weed out on this VC? It is probably 2000 lines of code and i'm not even sure the problem lies in that VC as the debugger is so vague.
Any help would be greatly appreciated
This happened to me because I had a private enum in both the main class, and an extension of that class. Both of these were in the same file. Tricky one!
In my case, it appears that it was due to a local project scheme missing with a build phase in my application attempting to link to the project.
I have run into the same problem. I finally figured out that it was caused by overriding 'var description' on any class that inherits from NSObject. I note that in Swift 3.1 there is a 'class func description()' on NSObject that I don't necessarily recall being in Swift 3.0 (although I could easily be mistaken in this assumption; I've never had any to look for or use it). See also https://forums.developer.apple.com/thread/75700
I faced the error because my class had a diffrent name than the filename. Corrected filename and everything worked fine then
In my case was because I put a ! symbol in a init method of a object. Like this:
init(obj1: Object1, obj2: Object2!) {
}
Remove the ! of function parameter and no more error.
I had similar issues with Swift classes that had properties with type RCTRootView from React. I fixed it by making the property private, turning something like this:
class MyViewController: UIViewController {
var rctView: RCTRootView()
}
Into something like this:
class MyViewController: UIViewController {
private var rctView: RCTRootView()
}
It seems that the error is in trying to deserialize classes from other modules/frameworks too early in compilation (in your case FirebaseDatabase and in my case React). Making this property private makes it so that the compiler doesn't need to do this till later in compilation. If I had to guess, it looks like we're sweeping some dependency/build order problems under the rug.
I fixed this by switching to a different device in the simulator - it then compiled and ran fine.
Then, when I went back to the previous device it also worked fine.
I've no explanation!
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.
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.