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

[SR-11074] Segmentation fault 11 Xcode 11 beta 3 #53466

Closed
swift-ci opened this issue Jul 5, 2019 · 7 comments
Closed

[SR-11074] Segmentation fault 11 Xcode 11 beta 3 #53466

swift-ci opened this issue Jul 5, 2019 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 5, 2019

Previous ID SR-11074
Radar rdar://problem/52804269
Original Reporter dasoga (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

macOC Mojave (10.14.5)

Xcode Version 11.0 beta 3 (11M362v)

Library is in Swift 4

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: 7e389cbe60ee9ec6c8eaefa2e0b9f9fc

duplicates:

  • SR-10728 Conditional Conformance Compiler Crash

Issue Description:

Segmentation fault: 11 Xcode 11 beta 3
I updated Xcode 11 beta 2 to beta 3 and I got a compiler crash with legacy library.

Can somebody help me to identify if this is a bug in this beta? thanks in advance

I have this protocol:

public typealias DexProgressCallback = (Double, Double) -> Void
 
public protocol DexCommand {
associatedtype ResultType
static var operationFactory: OperationFactory { get }
}
 
extension DexCommand {
public typealias SnailOperationCreator = (_ command: Self, _ delegate: DexOperationDelegate, _ connectionQueue: DispatchQueue, _ callbackQueue: DispatchQueue?, _ success: @escaping (ResultType) -> Void, _ failure: @escaping (Error) -> Void) -> SnailOperationBase?
public typealias VIUOperationCreator = (_ command: Self, _ delegate: DexOperationDelegate, _ connectionQueue: DispatchQueue, _ callbackQueue: DispatchQueue?, _ success: @escaping (ResultType) -> Void, _ failure: @escaping (Error) -> Void) -> VIUOperationBase?
public typealias UCSOperationCreator = (_ command: Self, _ delegate: DexOperationDelegate, _ connectionQueue: DispatchQueue, _ callbackQueue: DispatchQueue?, _ success: @escaping (ResultType) -> Void, _ failure: @escaping (Error) -> Void) -> UCSOperationBase?
public typealias OperationFactory = (snail: SnailOperationCreator?, viu: VIUOperationCreator?, ucs: UCSOperationCreator?)
 
func snailOperation(delegate: DexOperationDelegate, connectionQueue: DispatchQueue, callbackQueue: DispatchQueue?, success: @escaping (ResultType) -> Void, failure:@escaping (Error) -> Void) -> SnailOperationBase? {
return Self.operationFactory.snail?(self, delegate, connectionQueue, callbackQueue, success, failure)
}
 
func viuOperation(delegate: DexOperationDelegate, connectionQueue: DispatchQueue, callbackQueue: DispatchQueue?, success: @escaping (ResultType) -> Void, failure: @escaping (Error) -> Void) -> VIUOperationBase? {
return Self.operationFactory.viu?(self, delegate, connectionQueue, callbackQueue, success, failure)
}
 
func ucsOperation(delegate: DexOperationDelegate, connectionQueue: DispatchQueue, callbackQueue: DispatchQueue?, success: @escaping (ResultType) -> Void, failure: @escaping (Error) -> Void) -> UCSOperationBase? {
return Self.operationFactory.ucs?(self, delegate, connectionQueue, callbackQueue, success, failure)
}
}
 
extension DexCommand {
static func bind
<SnailOperationType: SnailOperation<Self>, VIUOperationType: VIUOperation<Self>, UCSOperationType: UCSOperation<Self>>
(snail: SnailOperationType.Type? = nil, viu: VIUOperationType.Type? = nil, ucs: UCSOperationType.Type? = nil)
-> OperationFactory
{
let snailOperationCreator: SnailOperationCreator?
 
if let operationType = snail {
snailOperationCreator = { command, delegate, connectionQueue, callbackQueue, success, failure in
operationType.init(command: command, delegate: delegate, connectionQueue: connectionQueue, callbackQueue: callbackQueue, success: success, failure: failure)
}
}
else {
snailOperationCreator = nil
}
 
let viuOperationCreator: VIUOperationCreator?
 
if let operationType = viu {
viuOperationCreator = { command, delegate, connectionQueue, callbackQueue, success, failure in
operationType.init(command: command, delegate: delegate, connectionQueue: connectionQueue, callbackQueue: callbackQueue, success: success, failure: failure)
}
}
else {
viuOperationCreator = nil
}
 
let ucsOperationCreator: UCSOperationCreator?
 
if let operationType = ucs {
ucsOperationCreator = { command, delegate, connectionQueue, callbackQueue, success, failure in
operationType.init(command: command, delegate: delegate, connectionQueue: connectionQueue, callbackQueue: callbackQueue, success: success, failure: failure)
}
}
else {
ucsOperationCreator = nil
}
 
return (snail: snailOperationCreator, viu: viuOperationCreator, ucs: ucsOperationCreator)
}
}

This is the stack:

1. While type-checking protocol conformance to 'DexCommand' (at /Users/dasoga/.../DexCommand.swift:13:8) for type 'UpdateMachine' (declared at [/Users/dasoga/.../UpdateMachine.swift:16:8 - line:39:1] RangeText="struct UpdateMachine: DexCommand, CustomStringConvertible {
public typealias ResultType = Void
public static let operationFactory = bind(snail: UpdateMachineSnail.self, viu: UpdateMachineVIU.self, ucs: UpdateMachineUCS.self)
 
let progress: DexProgressCallback?
let progressQueue: DispatchQueue
let machineType: MachineType
 
public var description: String {
return "UpdateMachine(password: \(dex.password), machineType: \(machineType.rawValue), isV21: \(dex.isV21), rawCommands(\(rawCommands.count)): \(rawCommands))"
}
 
fileprivate let dex: Dex
fileprivate let rawCommands: [String]
 
// if the ID1 line in the dex indicates that this machine is a v21, it will take precedence over the machineType parameter
public init(dex: Dex, machineType: MachineType, updatedSelections: [Dex.Selection], progress: DexProgressCallback? = nil, progressQueue: DispatchQueue = .main) {
self.dex = dex
self.progress = progress
self.progressQueue = progressQueue
self.machineType = machineType
self.rawCommands = machineType.generateCommands(dex: dex, updatedSelections: updatedSelections)
}
")
0  swift                    0x0000000104d22c83 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x0000000104d22456 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff58c09b5d _sigtramp + 29
3  swift                    0x000000010167295c swift::ClangImporter::Implementation::lookupValue(swift::SwiftLookupTable&, swift::DeclName, swift::VisibleDeclConsumer&) + 540
4  swift                    0x00000001014a1e8a swift::constraints::ConstraintLocatorBuilder::trySimplifyToExpr() const + 122
5  swift                    0x000000010139ce41 swift::constraints::ConstraintSystem::matchFunctionTypes(swift::FunctionType*, swift::FunctionType*, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 1489
6  swift                    0x0000000101384e84 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 4484
7  swift                    0x00000001013a0e2b swift::constraints::ConstraintSystem::simplifyRestrictedConstraintImpl(swift::constraints::ConversionRestrictionKind, swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 11099
8  swift                    0x000000010138a84c swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 27468
9  swift                    0x0000000101385257 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 5463
10 swift                    0x00000001013837dd swift::constraints::ConstraintSystem::addConstraint(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 125
11 swift                    0x00000001015129b3 llvm::Optional<swift::RequirementMatch> llvm::function_ref<llvm::Optional<swift::RequirementMatch> (swift::Type, swift::Type)>::callback_fn<swift::matchWitness(swift::TypeChecker&, llvm::DenseMap<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment, llvm::DenseMapInfo<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*> >, llvm::detail::DenseMapPair<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::ProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*)::$_1>(long, swift::Type, swift::Type) + 83
12 swift                    0x0000000101510ff5 swift::matchWitness(swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*, llvm::function_ref<std::__1::tuple<llvm::Optional<swift::RequirementMatch>, swift::Type, swift::Type> ()>, llvm::function_ref<llvm::Optional<swift::RequirementMatch> (swift::Type, swift::Type)>, llvm::function_ref<swift::RequirementMatch (bool, llvm::ArrayRef<swift::OptionalAdjustment>)>) + 3477
13 swift                    0x000000010151267e swift::matchWitness(swift::TypeChecker&, llvm::DenseMap<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment, llvm::DenseMapInfo<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*> >, llvm::detail::DenseMapPair<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::ProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*) + 1166
14 swift                    0x0000000101514ce5 swift::WitnessChecker::findBestWitness(swift::ValueDecl*, bool*, swift::NormalProtocolConformance*, llvm::SmallVectorImpl<swift::RequirementMatch>&, unsigned int&, unsigned int&, bool&) + 1573
15 swift                    0x000000010151f15d swift::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*) + 653
16 swift                    0x000000010151a256 swift::MultiConformanceChecker::checkIndividualConformance(swift::NormalProtocolConformance*, bool) + 11958
17 swift                    0x0000000101516ef2 swift::MultiConformanceChecker::checkAllConformances() + 130
18 swift                    0x000000010152f3ee swift::TypeChecker::checkConformancesInContext(swift::DeclContext*, swift::IterableDeclContext*) + 7214
19 swift                    0x000000010157eab5 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1957
20 swift                    0x0000000100c76635 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 5877
21 swift                    0x000000010096e03a performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 794
22 swift                    0x000000010096a474 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6868
23 swift                    0x00000001008f8fb3 main + 1219
24 libdyld.dylib            0x00007fff58a1e3d5 start + 1
25 libdyld.dylib            0x0000000000000075 start + 2807962785
error: Segmentation fault: 11 (in target 'iOSDEX')
@belkadan
Copy link
Contributor

belkadan commented Jul 6, 2019

Any compiler crash is a bug, so thank you for filing!

@belkadan
Copy link
Contributor

belkadan commented Jul 6, 2019

@DougGregor, @xedin, does this look familiar?

dasoga (JIRA User), do you have a self-contained test case?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jul 6, 2019

Comment by Dante Solorio (JIRA)

Not really @belkadan

@belkadan
Copy link
Contributor

belkadan commented Jul 8, 2019

Even if you could share your project, it would help. As is, you haven't shared the code that actually crashes, and the protocol references types that are outside the code you did share.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jul 8, 2019

Comment by Dante Solorio (JIRA)

Ok @belkadan I just attached the whole library. Thanks for your help.

@belkadan
Copy link
Contributor

belkadan commented Jul 9, 2019

Thank you!

@swift-ci create

@beccadax
Copy link
Contributor

Reduced the project down to:

// These typealiases just represent types that can be arbitrary as long as they
// line up. Set them to any type you want, or substitute them, and it'll still
// reproduce.
typealias T1 = Int
typealias T2 = Float
typealias T3 = Bool

protocol DexCommand {
    associatedtype ResultType
    static var operationFactory: (T1, (ResultType) -> T2) { get }
}

extension DexCommand {
  static func bind() -> (T1, (ResultType) -> T2) {
        fatalError()
    }
}

struct TestVIUSignalStrength: DexCommand {
  typealias ResultType = T3
  static let operationFactory: (T1, (ResultType) -> T2) = bind()
}

The dependencies and project configuration don't matter—this will reproduce on the command line with swift DexCommand.swift.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

4 participants