3
votes

I have an error "Command failed due to signal: Segmentation fault: 11" when I compile my Swift code with a library Eureka. I am using Xcode Version 7.3 (7D175). My situation is similar to this question.

In the question above, some people were getting the same error with Eureka but it doesn't help me. I have just created a new project and done "pod install". Then I added "AgeRow.swift". So, this project is minimum and clean.

Here is a small sample that causes the segmentation fault error.

Please make sure this sample depends on Eureka 1.5.0.

I am writing my custom row named AgeInlineRow. When I comment out the AgeInlineRow class, the sample can be compiled. That is, other code seems not to be the cause of the error.

public final class AgeInlineRow: _AgeInlineRow, RowType, InlineRowType {

    required public init(tag: String?) {
        super.init(tag: tag)
        onExpandInlineRow { cell, row, _ in
            let color = cell.detailTextLabel?.textColor
            row.onCollapseInlineRow { cell, _, _ in
                cell.detailTextLabel?.textColor = color
            }
            cell.detailTextLabel?.textColor = cell.tintColor
        }
    }

    public override func customDidSelect() {
        super.customDidSelect()
        if !isDisabled {
            toggleInlineRow()
        }
    }

    public func setupInlineRow(inlineRow: InlineRow) {
        inlineRow.year_options = self.year_options
        inlineRow.month_options = self.month_options
        inlineRow.displayValueFor = self.displayValueFor
    }
}

When I remove InlineRowType protocol and modify code to compile, this project can be compiled. So, I guess the cause is InlineRowType protocol and this is the limits of my debug abilities. I have no idea how can I bypass the issue. I have copied Eureka's PickerInlineRow code and modified. Of course PickerInlineRow doesn't cause segmentation fault.

I would be grateful if you could specify the reasons.

Here is the error message below.

0  swift                    0x0000000108f344eb llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x0000000108f337d6 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x0000000108f34b4f SignalHandler(int) + 287
3  libsystem_platform.dylib 0x00007fff919e252a _sigtramp + 26
4  swift                    0x0000000108d5f78b llvm::FoldingSet<llvm::AttributeSetNode>::NodeEquals(llvm::FoldingSetImpl::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) const + 59
5  swift                    0x000000010835e15f llvm::CallInst::Create(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&, llvm::Instruction*) + 367
6  swift                    0x000000010835e2f0 llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >::CreateCall(llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&) + 64
7  swift                    0x0000000106d869c5 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 1829
8  swift                    0x0000000106d1a0dd swift::irgen::IRGenModuleDispatcher::emitGlobalTopLevel() + 861
9  swift                    0x0000000106da5a5e performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1278
10 swift                    0x0000000106da5f06 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 70
11 swift                    0x0000000106c89a1c performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 15004
12 swift                    0x0000000106c8541d frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
13 swift                    0x0000000106c80e3c main + 1932
14 libdyld.dylib            0x00007fff91af25ad start + 1
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/keta/Documents/Swift/AgeInlineRowSample/AgeInlineRowSample/ViewController.swift /Users/keta/Documents/Swift/AgeInlineRowSample/AgeInlineRowSample/AppDelegate.swift -primary-file /Users/keta/Documents/Swift/AgeInlineRowSample/AgeInlineRowSample/AgeRow.swift -target x86_64-apple-ios9.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -I /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Products/Debug-iphonesimulator -F /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Products/Debug-iphonesimulator -F /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Products/Debug-iphonesimulator/Eureka -enable-testing -g -module-cache-path /Users/keta/Library/Developer/Xcode/DerivedData/ModuleCache -D COCOAPODS -serialize-debugging-options -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/AgeInlineRowSample-generated-files.hmap -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/AgeInlineRowSample-own-target-headers.hmap -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/AgeInlineRowSample-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/AgeInlineRowSample-project-headers.hmap -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/DerivedSources/x86_64 -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DCOCOAPODS=1 -Xcc -working-directory/Users/keta/Documents/Swift/AgeInlineRowSample -emit-module-doc-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow~partial.swiftdoc -Onone -module-name AgeInlineRowSample -emit-module-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow~partial.swiftmodule -serialize-diagnostics-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow.dia -emit-dependencies-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow.d -emit-reference-dependencies-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow.swiftdeps -o /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow.o 

P.S. I would like to make a custom inline row that has UIPickerView with two components.

1

1 Answers

2
votes

I ran into this when i was implementing DateInlineRow. It seems swift compiler can not infer some types.

I ended up making DateInlineRow generic, even though i don't need the generic type for DateInlineRow.

Check out DateInlineRow implementation

/// A row with an NSDate as value where the user can select a date from an inline picker view.
public final class DateInlineRow_<T>: _DateInlineRow, RowType, InlineRowType {
    required public init(tag: String?) {
        super.init(tag: tag)
        onExpandInlineRow { cell, row, _ in
            let color = cell.detailTextLabel?.textColor
            row.onCollapseInlineRow { cell, _, _ in
                cell.detailTextLabel?.textColor = color
            }
            cell.detailTextLabel?.textColor = cell.tintColor
        }
    }

    public override func customDidSelect() {
        super.customDidSelect()
        if !isDisabled {
            toggleInlineRow()
        }
    }
}

public typealias DateInlineRow = DateInlineRow_<NSDate>

According to this your implementation should be.....

public final class AgeInlineRow_<T>: _AgeInlineRow, RowType, InlineRowType {

    .....
}

public typealias AgeInlineRow = AgeInlineRow_<String>

Hope it helps