Swift compiler segmentation fault with generic recursive function - ios

I've run into an interesting issue with the Swift compiler, which seems to be caused by a very simple generic function. I've got a workaround, but I'd really like to understand what the underlying issue is.
In my app I have a requirement to fade in some UICollectionViewCells in a given order, sequentially, with a slight overlap between the animations.
I've implemented this using the methods below. The revealCells method takes an array of cells. If the collection is empty, it simply returns. Otherwise it animates the fade-in on the first cell in the array, and then waits a certain amount of time before making a recursive call to itself, passing all the cells except the one it just animated.
Code below:
func revealCells(cells:[UICollectionViewCell],animationTime:NSTimeInterval,overlap:Double) {
if cells.count > 0 {
let firstCell = cells.first
UIView.animateWithDuration(0.3, animations: { () -> Void in
firstCell?.alpha = 1.0
let timeMinusOverlap = animationTime - overlap
let delayTime = dispatch_time(DISPATCH_TIME_NOW,Int64(timeMinusOverlap * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue(), { () -> Void in
self.revealCells(self.cdr(cells),animationTime: animationTime,overlap: overlap)
})
})
}
}
}
//Returns the collection passed into the function with its first element removed
//i.e the traditional LISP cdr function
func cdr<T>(input:[T]) -> [T] {
var rVal = [T]()
if input.count == 1 {
rVal.append(input.first!)
} else {
rVal = [T](input[1...input.count-1])
}
return rVal
}
All this works fine in the simulator. But when I try to archive the build, the swift compiler crashes with the message Swift Compiler Error Command failed due to signal: Segmentation fault 11. My setup is Xcode 6.3.1 (iOSSDK 8.3), and my min deployment target is 8.3.
Fixing the problem is trivial - if I just replace the code inside the dispatch_after with:
let newCells = [UICollectionViewCell](cells[1...cells.count-1])
self.revealCells(newCells,animationTime: animationTime,overlap: overlap)
the problem goes away. So it seems to be something to do with the generic function, or possibly something block related.
Stack trace is:
0 swift 0x000000010105ba18 llvm::sys::PrintStackTrace(__sFILE*) + 40
1 swift 0x000000010105bef4 SignalHandler(int) + 452
2 libsystem_platform.dylib 0x00007fff8725ef1a _sigtramp + 26
3 libsystem_platform.dylib 0x000000000000000f _sigtramp + 2027557135
4 swift 0x00000001021a98cb llvm::AsmPrinter::EmitFunctionBody() + 4379
5 swift 0x000000010116c84c llvm::ARMAsmPrinter::runOnMachineFunction(llvm::MachineFunction&) + 220
6 swift 0x0000000100d81d13 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 99
7 swift 0x00000001024d5edf llvm::FPPassManager::runOnFunction(llvm::Function&) + 495
8 swift 0x00000001024d60cb llvm::FPPassManager::runOnModule(llvm::Module&) + 43
9 swift 0x00000001024d658f llvm::legacy::PassManagerImpl::run(llvm::Module&) + 975
10 swift 0x0000000100a09b41 performIRGeneration(swift::IRGenOptions&, swift::Module*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 4369
11 swift 0x0000000100a09cb3 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 51
12 swift 0x0000000100945687 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 6647
13 swift 0x0000000100943ae6 main + 1814
14 libdyld.dylib 0x00007fff8a46b5c9 start + 1
(a long list of program arguments, which are mostly the names of file being compiled)
1. Running pass 'Function Pass Manager' on module '/Users/tolleyr/Library/Developer/Xcode/DerivedData/ParseTestQuiz-fgnfjkxxlyqfnrfrfntgtsjnrcfv/Build/Intermediates/ArchiveIntermediates/ParseTestQuiz/IntermediateBuildFilesPath/ParseTestQuiz.build/Release-iphoneos/ParseTestQuiz.build/Objects-normal/armv7/QuizQuestionViewController.o'.
2. Running pass 'ARM Assembly / Object Emitter' on function '#_TFC13ParseTestQuiz26QuizQuestionViewController13viewDidAppearfS0_FSbT_'
(the last part enabled me to figure out what code was causing the problem). The command being run was CompileSwift normal armv7
I'm going to file a radar for this, since the compiler itself is crashing , but thought I'd post it here in case anyone has an idea of what might be going on, or has run into the same issue.

Related

Invalid Mutability Exception when using background threads in KMM project on iOS

I am working on a KMM project and am currently developing a model layer. In order to work with data I was planning to create a singleton like so:
#ThreadLocal object Repository {
private var dao: DataAccessObject? = null
private val scope = CoroutineScope(Dispatchers.Main)
fun injectDao(dao: DataAccessObject) {
scope.async {
Repository.dao = dao
}
}
suspend fun create(dataObjectType: TypeOfDataObject): DataObject? {
var dataObject: DataObject? = null
val job = scope.async {
dataObject = dao?.create(dataObjectType = dataObjectType)
}
job.await()
return dataObject
}
}
In such implementation as you see the request to the database is handled in Main thread, which's quite not good. But it works and the data is returned from the function correctly. The next obvious step is to try to run it in background scope. To make it we should just redeclare scope:
private val scope = CoroutineScope(Dispatchers.Default)
When we run the code and call create function from somewhere it falls with
Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.native.internal.Ref#5761ad88
2021-02-02 23:54:50.408645+0300 Plendy[28960:2893398] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
at 0 Shared 0x000000010d51640f kfun:kotlin.Throwable#<init>(kotlin.String?){} + 95 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/Throwable.kt:23:37)
at 1 Shared 0x000000010d50f0bd kfun:kotlin.Exception#<init>(kotlin.String?){} + 93 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
at 2 Shared 0x000000010d50f32d kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 93 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
at 3 Shared 0x000000010d5448cd kfun:kotlin.native.concurrent.InvalidMutabilityException#<init>(kotlin.String){} + 93 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:22:60)
at 4 Shared 0x000000010d5460af ThrowInvalidMutabilityException + 431 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:92:11)
at 5 Shared 0x000000010d6470b0 MutationCheck + 128
at 6 Shared 0x000000010d5640f8 kfun:kotlin.native.internal.Ref#<set-element>(1:0){} + 104 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/native/internal/Ref.kt:12:5)
at 7 Shared 0x000000010d4a1d5b kfun:com.plendy.PlendyCore.Model.KNPlendyData.$create$lambda-1COROUTINE$4.invokeSuspend#internal + 779 (/Users/petr/Documents/Projects/Plendy/Android/Plendy/PlendyCore/src/commonMain/kotlin/com/plendy/PlendyCore/Model/KNPlendyData.kt:23:13)
at 8 Shared 0x000000010d537958 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 760 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:30:39)
at 9 Shared 0x000000010d6d7a78 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2680 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:106:71)
at 10 Shared 0x000000010d687fb8 kfun:kotlinx.coroutines.EventLoopImplBase#processNextEvent(){}kotlin.Long + 840 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/EventLoop.common.kt:274:18)
at 11 Shared 0x000000010d6efbbb kfun:kotlinx.coroutines#runEventLoop(kotlinx.coroutines.EventLoop?;kotlin.Function0<kotlin.Boolean>){} + 843 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Builders.kt:80:40)
at 12 Shared 0x000000010d6f8d39 kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.start$lambda-0#internal + 409 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:49:17)
at 13 Shared 0x000000010d6f8f30 kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$35.invoke#internal + 64 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
at 14 Shared 0x000000010d6f8f90 kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$35.$<bridge-UNN>invoke(){}#internal + 64 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
at 15 Shared 0x000000010d545d59 WorkerLaunchpad + 185 (/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:69:54)
at 16 Shared 0x000000010d64ba4f _ZN6Worker19processQueueElementEb + 3135
at 17 Shared 0x000000010d64adf6 _ZN12_GLOBAL__N_113workerRoutineEPv + 54
at 18 libsystem_pthread.dylib 0x0000000110a86950 _pthread_start + 224
at 19 libsystem_pthread.dylib 0x0000000110a8247b thread_start + 15
What is strange that the data is written to the db, meaning that dao is called successfully, but data isn't returning from the function, because the exception occurs earlier. At this point I don't understand to what frozen object does the exception relates? What I've tried next is to remove job.await() line and it worked perfectly with no exceptions besides of cause having null in function's output.
So my question is: how to make code run in a background thread still having an ability to wait for its output?
You should include more of the exception info to help figure out what's happening, and you can use ensureNeverFrozen to help identify when something is being inadvertently frozen. However, in this case, I think I can figure it out.
In this case, capturing a reference to dataObject in your background lambda will freeze it. Trying to reassign it is (probably) throwing your exception.
var dataObject: DataObject? = null
val job = scope.async {
//Trying to assign the frozen dataObject will fail
dataObject = dao?.create(dataObjectType = dataObjectType)
}
Since you're already in a suspend function, why not just use something like withContext?
suspend fun create(dataObjectType: TypeOfDataObject): DataObject? {
val dataObject = withContext(Dispatchers.Default) {
dao?.create(dataObjectType = dataObjectType)
}
return dataObject
}
And if you're going that far ...
suspend fun create(dataObjectType: TypeOfDataObject): DataObject? = withContext(Dispatchers.Default) {
dao?.create(dataObjectType = dataObjectType)
}

Workaround for specific generic type parameter

The situation:
I have two protocols, one with a static method:
protocol DataSourceable {
static func getMoreData<T: DataAccepting>(someObject: T)
}
protocol DataAccepting {
func accept(data: [Any])
}
extension DataAccepting where Self: UIViewController { }
which compiles fine.
Once I define a class with a type parameter conforming to DataSourceable:
class SampleViewController<T: DataSourceable>: UIViewController {...}
I get a Segmentation Fault: 11 and the compiler crashes.
0 swift 0x0000000112445b6d PrintStackTraceSignalHandler(void*) + 45
1 swift 0x00000001124455b6 SignalHandler(int) + 470
2 libsystem_platform.dylib 0x00007fffa4bd9bba _sigtramp + 26
3 libsystem_platform.dylib 0x0000000000000002 _sigtramp + 1531077730
4 swift 0x000000010f8bd5bd swift::irgen::emitCategoryData(swift::irgen::IRGenModule&, swift::ExtensionDecl*) + 2285
5 swift 0x000000010f8c2425 swift::irgen::IRGenModule::emitGlobalDecl(swift::Decl*) + 1189
6 swift 0x000000010f8c1e85 swift::irgen::IRGenModule::emitSourceFile(swift::SourceFile&, unsigned int) + 133
7 swift 0x000000010f98dfe2 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1282
8 swift 0x000000010f85c1c7 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 23687
9 swift 0x000000010f854265 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029
10 swift 0x000000010f81182d main + 8685
11 libdyld.dylib 0x00007fffa49cd255 start + 1
12 libdyld.dylib 0x00000000000000c6 start + 1533226610
**More_Stuff**...
While emitting IR for source file /xx/xx/xx/xx/xx/xx/xx/SampleViewController.swift
The end goal is to be able to do this:
class SampleViewController<T: DataSourceable>: UIViewController, DataAccepting {
var intArray = [Int]()
func setup() {
T.getMoreData(dataAcceptor: self)
}
func accept(data: [Any]) {
intArray = data
}
}
struct SampleModel: DataSourceable {
static func getMoreData<T: DataAccepting>(dataAcceptor: T) {
var anIntArray = [Int]()
someObject.accept(anIntArray)
}
}
And then make a SampleViewController<SampleModel>.
This will allow me to let the SampleModel deal with sourcing data for the controller. The SampleModel decides how to get the data, then using the accept() function on the controller it can give the data to the SampleController.
This seems to be a compiler bug. However, you should avoid this design in general, as we discussed in chat.

Swift compiler segmentation fault after Swift 3 / Xcode 8 port

I have checked multiple answers here in SO, but no solution seems to work for me. When compiling my iOS (≥9.3) app, the following compiler error appears since I converted my project to Swift 3 / Xcode 8.
I tried to clean, delete DerivedData, rebuild Carthage frameworks, etc. - but nothing worked - yet.
Maybe somebody who has experienced this before can immediately spot the problem.
Console output / Stacktrace :
0 swift 0x000000010bc8cb6d PrintStackTraceSignalHandler(void*) + 45
1 swift 0x000000010bc8c5b6 SignalHandler(int) + 470
2 libsystem_platform.dylib 0x00007fffd300dbba _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 754918496
4 swift 0x00000001090c98d2 llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 530
5 swift 0x00000001091a7600 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 240
6 swift 0x00000001090c96a7 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 247
7 swift 0x00000001091a39cd swift::SILWitnessVisitor<(anonymous namespace)::WitnessTableBuilder>::visitProtocolDecl(swift::ProtocolDecl*) + 5997
8 swift 0x00000001091a14d7 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 503
9 swift 0x00000001091138ed swift::irgen::IRGenerator::emitGlobalTopLevel() + 2077
10 swift 0x00000001091d4fcb performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1259
11 swift 0x00000001090a31c7 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 23687
12 swift 0x000000010909b265 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029
13 swift 0x000000010905882d main + 8685
14 libdyld.dylib 0x00007fffd2e01255 start + 1
15 libdyld.dylib 0x0000000000000067 start + 757067283
And the problematic file / class is the following:
class JSONDataProvider<Input, Output, APIInformation>: DataProvider
where APIInformation: APIAccessInformation, APIInformation.Input == Input,
Output: JSONDataType, Input: Equatable, Input: SignificanceComparable
{
static var updateCallbacksWithoutInputChange: Bool { return false }
// MARK: - Protocol Variables
var callbackId: Int = 0
var callbacks: [Int : (Result<(Output, Input)>) -> ()]
var inputCache: Input?
var outputCache: Result<(Output, Input)>?
// MARK: - Private Properties
fileprivate let apiInformation: APIInformation
fileprivate let requestHandler: URLRequestHandler
// MARK: - Init
init(apiInformation: APIInformation, requestHandler: URLRequestHandler)
{
self.apiInformation = apiInformation
self.requestHandler = requestHandler
self.callbacks = [:]
}
}
For context: (leaving out extensions)
protocol DataProvider
{
associatedtype Input: Equatable, SignificanceComparable
associatedtype Output
static var updateCallbacksWithoutInputChange: Bool { get }
var inputCache: Input? { get set }
var outputCache: Result<(Output, Input)>? { get set }
var callbackId: Int { get set }
var callbacks: [Int : (Result<(Output, Input)>) -> Void] { get set }
func fetchData(from input: Input)
mutating func registerCallback(_ callback: #escaping (Result<(Output, Input)>) -> Void) -> Int
mutating func unregisterCallback(with id: Int)
}
And:
protocol APIAccessInformation
{
associatedtype Input: Equatable, SignificanceComparable
var requestMethod: Alamofire.HTTPMethod { get }
var baseURL: String { get }
func apiParameters(for input: Input) -> [String : Any]
}
Any ideas? Thank you!
Turns out the generic type was the problem. As nobody seems to know exactly why, I have adapted my architecture so I don't need this generic type.
I'm leaving this question here in case others run into a similar issue or someone who knows the exact reason and fix finds this thread.

Segmentation Fault: 11 - Xcode 6.3

Can't archive
My app runs fine (Xcode 6.3.2, swift based) on Simulator and on multiple devices. But when I try to archive it I get the error Command failed due to signal: Segmentation fault: 11.
Others face same problem
Segmentation Fault 11 when running Swift app
"Command failed due to signal: Segmentation fault: 11" - What is the issue?
Command failed due to signal: Segmentation fault: 11
Root cause?
But it seems that each have different reasons for getting the error.. I am unable to comprehend the error message I am getting. Posted below, any hints or tips would be greatly appreciated!
Error log
0 swift 0x0000000108e5d2b8 llvm::sys::PrintStackTrace(__sFILE*) + 40
1 swift 0x0000000108e5d794 SignalHandler(int) + 452
2 libsystem_platform.dylib 0x00007fff8897bf1a _sigtramp + 26
3 libsystem_platform.dylib 0x00007fff574b7b28 _sigtramp + 3467885608
4 swift 0x0000000108a053f2 swift::serialization::Serializer::writeCrossReference(swift::Decl const*) + 578
5 swift 0x0000000108a0e275 swift::serialization::Serializer::writeAllDeclsAndTypes() + 2181
6 swift 0x0000000108a0f2f8 swift::serialization::Serializer::writeAST(llvm::PointerUnion<swift::Module*, swift::SourceFile*>) + 2600
7 swift 0x0000000108a11960 swift::serialization::Serializer::writeToStream(llvm::raw_ostream&, llvm::PointerUnion<swift::Module*, swift::SourceFile*>, swift::SILModule const*, swift::SerializationOptions const&) + 144
8 swift 0x0000000108a12521 swift::serialize(llvm::PointerUnion<swift::Module*, swift::SourceFile*>, swift::SerializationOptions const&, swift::SILModule const*) + 321
9 swift 0x0000000108746c1a frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 5514
10 swift 0x00000001087454e6 main + 1814
11 libdyld.dylib 0x00007fff8db235c9 start + 1
12 libdyld.dylib 0x0000000000000080 start + 1917700792
Solved it. Problem was two things:
1) Converting to Double
2) Handling an empty array
Converting to Double
Changed from var lat: Double? = d["lat"].doubleValue to var lat: Double? = Double(d["lat"].doubleValue)
Handling an empty array
Changed from
let brands = d["brands_unfiltered"].arrayValue {
if brands == [] {
// Do nothing (empty)
}
else{
// Do stuff
}
To
if let brands = d["brands_unfiltered"].arrayValue as Array! {
// Do stuff
}
To find the root cause I deactivated larges part of the code until I found what got the archiving not to function. Thereafter the solution was pretty straight forward. Hope this helps someone else struggling with the same error.
I found the code that cause my "Archive" action to fail with this error "Command failed due to signal: Segmentation fault: 11"
When I use the indexPath in the cellForRowAtIndexPath function, I need to put an exclamation mark (i.e indexPath! instead of indexPath). However, I still puzzled by why there is such error if I omit the exclamation mark. Does anyone know the reason?
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell! {
// code to get cell, etc
let thumbnailImage = self.userPhotos?.getFromCacheOrDownload(username,
circle: team.circle(), delegate: self, indexPath: indexPath!)
cell.userPhotoImageView.image = thumbnailImage
return cell
}

MKMapViewDelegate Command failed due to signal: Segmentation fault: 11

i have a very weird problem with a MKMapViewDelegate when i implement this method give me an error that i do not understand
The error only disappear when i delete the whole function,
i tried to make a empty function returning nil but give me the same error.
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if annotation.isKindOfClass(MKUserLocation.classForCoder()) {
return nil
}
let AnnotationIdentifier:NSString = "AnnotationIdentifier"
var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier(AnnotationIdentifier)
if annotationView != nil {
return annotationView
}else {
var annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: AnnotationIdentifier)
annotationView.canShowCallout = true
annotationView.image = UIImage(named: "btn_fav.png")
return annotationView
}
}
The error:
Command failed due to signal: Segmentation fault: 11
CompileSwift normal arm64 /Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Vistas/Proyecto/MapaViewController.swift
cd /Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c "/Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Classes/NetClass/Downloader.swift" -primary-file "/Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Vistas/Proyecto/MapaViewController.swift" "/Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Vistas/Widget/ToggleView.swift" .
.
.
.
0 swift 0x00000001019df028 llvm::sys::PrintStackTrace(__sFILE*) + 40
1 swift 0x00000001019df514 SignalHandler(int) + 452
2 libsystem_platform.dylib 0x00007fff9a2dc5aa _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 1708276336
4 swift 0x0000000100fe90ea swift::ClangImporter::Implementation::loadAllMembers(swift::Decl const*, unsigned long long, bool*) + 3130
5 swift 0x0000000101da2834 swift::IterableDeclContext::loadAllMembers() const + 100
6 swift 0x0000000101d995dc swift::NominalTypeDecl::getMembers(bool) const + 28
7 swift 0x0000000101dc029f swift::NominalTypeDecl::lookupDirect(swift::DeclName) + 79
8 swift 0x0000000101dbe96a swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, unsigned int, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 3146
9 swift 0x0000000100fe5941 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 161
10 swift 0x0000000100fe0d0d clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3117
11 swift 0x0000000100fe005b swift::ClangImporter::Implementation::importDeclImpl(clang::NamedDecl const*, bool&, bool&) + 331
12 swift 0x0000000100fe4912 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool) + 226
13 swift 0x0000000100fe879e swift::ClangImporter::Implementation::loadAllMembers(swift::Decl const*, unsigned long long, bool*) + 750
14 swift 0x0000000101da2834 swift::IterableDeclContext::loadAllMembers() const + 100
15 swift 0x0000000101d99a95 swift::ExtensionDecl::getMembers(bool) const + 21
16 swift 0x0000000101dc027d swift::NominalTypeDecl::lookupDirect(swift::DeclName) + 45
17 swift 0x0000000101dbe96a swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, unsigned int, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 3146
18 swift 0x0000000101cc6288 swift::TypeChecker::lookupMember(swift::Type, swift::DeclName, swift::DeclContext*, bool) + 200
19 swift 0x0000000101c34e2c swift::constraints::ConstraintSystem::lookupMember(swift::Type, swift::DeclName) + 220
20 swift 0x0000000101c6b32d swift::constraints::ConstraintSystem::simplifyMemberConstraint(swift::constraints::Constraint const&) + 2173
21 swift 0x0000000101c6dc88 swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 216
22 swift 0x0000000101c354bc swift::constraints::ConstraintSystem::addConstraint(swift::constraints::Constraint*, bool, bool) + 28
23 swift 0x0000000101c5a8a5 swift::ASTVisitor<(anonymous namespace)::ConstraintGenerator, swift::Type, void, void, void, void, void>::visit(swift::Expr*) + 9317
24 swift 0x0000000101c5c502 (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 162
25 swift 0x0000000101d6627f (anonymous namespace)::Traversal::visit(swift::Expr*) + 6431
26 swift 0x0000000101d62765 swift::Expr::walk(swift::ASTWalker&) + 53
27 swift 0x0000000101c583b0 swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*) + 96
28 swift 0x0000000101c90ab6 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::Type, bool, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*) + 518
29 swift 0x0000000101cd73e3 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 291
30 swift 0x0000000101cd64c3 swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 371
31 swift 0x0000000101cd6b8f swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 95
32 swift 0x0000000101c86b65 typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 421
33 swift 0x0000000101c87476 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, unsigned int) + 1734
34 swift 0x0000000100fc07dd swift::CompilerInstance::performSema() + 2253
35 swift 0x0000000100d54831 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 1953
36 swift 0x0000000100d5294d main + 1677
37 libdyld.dylib 0x00007fff960e05fd start + 1
38 libdyld.dylib 0x0000000000000061 start + 1777465957
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Classes/NetClass/Downloader.swift -primary-file /Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Vistas/Proyecto/MapaViewController.swift /Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Vistas/Widget/ToggleView.swift /Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Classes/Entities/Mapa.swift /Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Classes/Entities/Edificio__c.swift .
.
.
.
.
1. While type-checking 'loadMapa' at /Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Vistas/Proyecto/MapaViewController.swift:56:5
2. While type-checking expression at [/Users/Fortis/Proyectos/IOS Apps/Abilia/Abilia iOS/Abilia/Abilia/Vistas/Proyecto/MapaViewController.swift:57:9 - line:57:29] RangeText="mapaView.delegate = s"
func loadMapa () {
mapaView.delegate = self
var theCoord = CLLocationCoordinate2DMake(0, 0)
if let coordenadasU = coordenadas {
let coordArray:[NSString] = coordenadasU.componentsSeparatedByString(",") as [NSString]
if coordArray.count > 1 {
let lat: CLLocationDegrees = coordArray[0].doubleValue;
let long: CLLocationDegrees = coordArray[1].doubleValue;
theCoord = CLLocationCoordinate2DMake(lat, long)
}
}
pointAnnotation.coordinate = theCoord;
mapaView.addAnnotation(pointAnnotation)
let span = MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1)
let region:MKCoordinateRegion = MKCoordinateRegion(center: theCoord, span: span)
mapaView.setRegion(region, animated: true)
mapaLoaded = true;
}
This is one of Swift's many bugs where the compiler suddenly crashes because of specific code in your app it cannot handle.
You have to isolate the problematic part (e.g. by commenting out parts of the screen) and once it compiles again find a workaround to use different code.
How does your method loadMapa look like? It's the cause the compiler mentioned.
I had same error when subclassing UIButton and overriding selected property like this:
class ActionButton: UIButton {
override var selected: Bool = true {
didSet {
updateBackgroundColor()
}
}
}
Solution was to remove ' = true' from the override statement:
class ActionButton: UIButton {
override var selected: Bool {
didSet {
updateBackgroundColor()
}
}
}
I'm just guessing but I would double-check if you implemented your delegate method exactly right way... With all exclamation marks correctly given... '!' at the end of MKAnnotationView! seems to be a bit suspicious.
I've searched why The error: "Command failed due to signal: Segmentation fault: 11" is causing problems in my app... My app is Parse dependent. I found out that Parse made changes to method:
query.findObjectsInBackgroundWithBlock({ (objects : [AnyObject]?, error : NSError?) -> Void in
to
query.findObjectsInBackgroundWithBlock({ (objects : [**PFObject**]?, error : NSError?) -> Void in
I've changed it all, and now it works. Hope this will help someone using Parse. Cheers
Not really a specific answer, but I wanted to add another possible cause of this bug (since it's still quite common).
My program had code like so:
if (myArray.count > 0) && (.Foo != myArray.last) {
// Do something
}
In my case .Foo belonged to an enum for which I'd implemented Equatable, however, for some reason the Swift compiler didn't highlight my comparison to myArray.last as an error (non-optional compared to optional) and produced a segmentation fault.
In my case the fix was simply to use myArray.last! since the myArray.count > 0 ensures this will always succeed (must be at least one element).
As usual, once you know what the bug is, be sure to pass it on to bug report.apple.com!

Resources