How to deal with a swift compiler error: Illegal instruction: 4

Hi There,

I am struggling with a compiler issue (Illegal instruction: 4). I am not sure how to handle the situation. I cannot share the source code and I cannot boil the problem down.

I found the problematic lines, but they look completely harmless. It is a call to a static function defined in another library (function defined on protocol but called on specific type).

Is there any way to find out more about the problem without digging into the compiler code? Can I somehow locate the problem in any other way?

Many thanks in advance!
Klaus

Can you provide the full error output?

Can you try reproducing the issue with a development snapshot from swift.org? Swift.org - Download Swift

These have assertions enabled; if an assertion is getting triggered, that may help in narrowing down the issue.

Hi Varun & Co,

I didn't know about these toolchains. Thank you very much.

I tried the snapshot from the 9th. Now I get an error message in a library that was compiling previously.
Please see below. Does it help in any way?

Btw, I make heavy use of protocols with associated types (PATs) in my code.

Many thanks in advance.

Kind regards,
Klaus

  1. Apple Swift version 5.3-dev (LLVM 618cb952e0f199a, Swift 4aa1ef39646ffa7)

  2. While evaluating request TypeCheckSourceFileRequest(source_file "/Users/klauskneupner/Documents/xcode/vithanco/VCore/TempCore/TempGraph.swift")

  3. While type-checking 'TempEdge' (at /Users/klauskneupner/Documents/xcode/vithanco/VCore/TempCore/TempGraph.swift:347:8)

  4. While type-checking protocol conformance to 'VEdge' (at /Users/klauskneupner/Documents/xcode/vithanco/VCore/Sources/VCore/VEdge.swift:60:8) for type 'TempEdge' (declared at [/Users/klauskneupner/Documents/xcode/vithanco/VCore/TempCore/TempGraph.swift:347:8 - line:437:1] RangeText="class TempEdge : VEdge, CleanUpNeeded {

public static var entityName: String = "TempEdge"

public var from: TempNode {

willSet {

from.outgoing.remove(self)

}

didSet {

from.outgoing.insert(self)

}

}

public var graph: TempGraph? {

willSet {

if let g = graph {

g.vEdges.removeObject(self)

}

}

didSet {

graph?.vEdges.append(self)

}

}

public var to: TempNode {

willSet {

from.incoming.remove(self)

}

didSet {

from.incoming.insert(self)

}

}

public func set(from: TempNode, to: TempNode){

self.from = from

self.to = to

}

public var type: EdgeType = .directed

public var created: Date? = nil

public var changed: Date? = nil

public var usedForRanking: Bool = true

public var edgeType: EdgeType = .directed

public var renderableText = FlexibleSizeText()

public var name: String {

return "TempEdge(self.uid)"

}

public typealias N = TempNode

public var uid: Int64 = nextID()

public var itemText: String = "TempEdge"

public var annotationText: String = "TempEdge"

public var drawingOrder: Int64 = nextID()

public var straighteningWeight: Int = 0

public var probability: Percent = 1.0

public func deleteYourself() {

}

public static func == (lhs: TempEdge, rhs: TempEdge) -> Bool {

return lhs === rhs

}

init(from: N, to: N) {

self.from = from

self.to = to

}

public var isValid: Bool {

return true

}

public var cldIsDelayed: Bool = false

deinit {

prepareDeinit()

}

public func prepareDeinit() {

graph = nil

}

")

  1. While evaluating request AbstractGenericSignatureRequest(NULL, {τ_0_0}, {τ_0_0 : TempEdge, τ_0_0 : VEdge})

0 swift-frontend 0x000000010f0dbb45 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37

1 swift-frontend 0x000000010f0dada5 llvm::sys::RunSignalHandlers() + 85

2 swift-frontend 0x000000010f0dc116 SignalHandler(int) + 262

3 libsystem_platform.dylib 0x00007fff6b7cb5fd _sigtramp + 29

4 libdyld.dylib 0x00007fff6b5d178f dyldGlobalLockRelease() + 0

5 libsystem_c.dylib 0x00007fff6b6a1808 abort + 120

6 libsystem_c.dylib 0x00007fff6b6a0ac6 err + 0

7 swift-frontend 0x000000010f63a5b3 bool (anonymous namespace)::removeSelfDerivedswift::Type(swift::GenericSignatureBuilder&, std::__1::vector<swift::GenericSignatureBuilder::Constraintswift::Type, std::__1::allocator<swift::GenericSignatureBuilder::Constraintswift::Type > >&, swift::ProtocolDecl*, bool, bool) (.cold.1) + 35

8 swift-frontend 0x000000010bb899c8 bool (anonymous namespace)::removeSelfDerivedswift::Type(swift::GenericSignatureBuilder&, std::__1::vector<swift::GenericSignatureBuilder::Constraintswift::Type, std::__1::allocator<swift::GenericSignatureBuilder::Constraintswift::Type > >&, swift::ProtocolDecl*, bool, bool) + 1224

9 swift-frontend 0x000000010bb89bec _ZN5swift23GenericSignatureBuilder19checkConstraintListINS_4TypeES2_EENS0_10ConstraintIT_EENS_12ArrayRefViewIS2_PNS_20GenericTypeParamTypeEL_ZNS_16staticCastHelperIS7_EEPS4_RKS2_ELb1EEERNSt3__16vectorIS5_NSE_9allocatorIS5_EEEEN4llvm12function_refIFbRKS5_EEENSL_IFNS0_18ConstraintRelationESN_EEENSK_8OptionalINS_4DiagIJjS2_T0_SV_EEEEENSU_IJS2_SV_EEENSU_IJjS2_SV_EEENSL_IFSV_RKS4_EEEb + 92

10 swift-frontend 0x000000010bb8398c swift::GenericSignatureBuilder::checkConcreteTypeConstraints(swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelperswift::GenericTypeParamType(swift::Type const&), true>, swift::GenericSignatureBuilder::EquivalenceClass*) + 332

11 swift-frontend 0x000000010bb821f1 swift::GenericSignatureBuilder::finalize(swift::SourceLoc, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelperswift::GenericTypeParamType(swift::Type const&), true>, bool) + 513

12 swift-frontend 0x000000010bb8b6ca swift::GenericSignatureBuilder::computeGenericSignature(swift::SourceLoc, bool, bool) && + 42

13 swift-frontend 0x000000010bb8c862 swift::AbstractGenericSignatureRequest::evaluate(swift::Evaluator&, swift::GenericSignatureImpl const*, llvm::SmallVector<swift::GenericTypeParamType*, 2u>, llvm::SmallVector<swift::Requirement, 2u>) const + 802

14 swift-frontend 0x000000010b821808 swift::GenericSignature swift::SimpleRequest<swift::AbstractGenericSignatureRequest, swift::GenericSignature (swift::GenericSignatureImpl const*, llvm::SmallVector<swift::GenericTypeParamType*, 2u>, llvm::SmallVector<swift::Requirement, 2u>), (swift::RequestFlags)2>::callDerived<0ul, 1ul, 2ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul, 1ul, 2ul>) const + 120

15 swift-frontend 0x000000010ba0f072 llvm::Expectedswift::AbstractGenericSignatureRequest::OutputType swift::Evaluator::getResultUncachedswift::AbstractGenericSignatureRequest(swift::AbstractGenericSignatureRequest const&) + 338

16 swift-frontend 0x000000010ba0ec95 llvm::Expectedswift::AbstractGenericSignatureRequest::OutputType swift::Evaluator::getResultCached<swift::AbstractGenericSignatureRequest, (void*)0>(swift::AbstractGenericSignatureRequest const&) + 213

17 swift-frontend 0x000000010b9fa24f swift::AbstractGenericSignatureRequest::OutputType swift::evaluateOrDefaultswift::AbstractGenericSignatureRequest(swift::Evaluator&, swift::AbstractGenericSignatureRequest, swift::AbstractGenericSignatureRequest::OutputType) + 63

18 swift-frontend 0x000000010bc0c35e swift::RequirementEnvironment::RequirementEnvironment(swift::DeclContext*, swift::GenericSignature, swift::ProtocolDecl*, swift::ClassDecl*, swift::ProtocolConformance*) + 2558

19 swift-frontend 0x000000010b7e08c7 swift::matchWitness(llvm::DenseMap<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*>, swift::RequirementEnvironment, llvm::DenseMapInfo<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*> >, llvm::detail::DenseMapPair<std::__1::pair<swift::GenericSignatureImpl const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::ProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*) + 471

20 swift-frontend 0x000000010b7e152e swift::WitnessChecker::findBestWitness(swift::ValueDecl*, bool*, swift::NormalProtocolConformance*, llvm::SmallVectorImplswift::RequirementMatch&, unsigned int&, unsigned int&, bool&) + 638

21 swift-frontend 0x000000010b7eb5d5 swift::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*) + 693

22 swift-frontend 0x000000010b7edfbb swift::ConformanceChecker::resolveValueWitnesses() + 363

23 swift-frontend 0x000000010b7e6a75 swift::ConformanceChecker::checkConformance(swift::MissingWitnessDiagnosisKind) + 245

24 swift-frontend 0x000000010b7e4931 swift::MultiConformanceChecker::checkIndividualConformance(swift::NormalProtocolConformance*, bool) + 8001

25 swift-frontend 0x000000010b7e2775 swift::MultiConformanceChecker::checkAllConformances() + 149

26 swift-frontend 0x000000010b7f0894 swift::TypeChecker::checkConformancesInContext(swift::IterableDeclContext*) + 5172

27 swift-frontend 0x000000010b7afba0 (anonymous namespace)::DeclChecker::visitClassDecl(swift::ClassDecl*) + 3424

28 swift-frontend 0x000000010b7ab96f (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 159

29 swift-frontend 0x000000010b7ab8b2 swift::TypeChecker::typeCheckDecl(swift::Decl*) + 130

30 swift-frontend 0x000000010b858ac8 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 184

31 swift-frontend 0x000000010b859b61 llvm::Expectedswift::TypeCheckSourceFileRequest::OutputType swift::Evaluator::getResultUncachedswift::TypeCheckSourceFileRequest(swift::TypeCheckSourceFileRequest const&) + 369

32 swift-frontend 0x000000010b8598c2 llvm::Expectedswift::TypeCheckSourceFileRequest::OutputType swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 66

33 swift-frontend 0x000000010b85980e llvm::Expectedswift::TypeCheckSourceFileRequest::OutputType swift::Evaluator::operator()<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 110

34 swift-frontend 0x000000010b85890e swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefaultswift::TypeCheckSourceFileRequest(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 46

35 swift-frontend 0x000000010aaf340a swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 90

36 swift-frontend 0x000000010aaf32fa swift::CompilerInstance::performSema() + 74

37 swift-frontend 0x000000010a9d7f5e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4718

38 swift-frontend 0x000000010a96e692 main + 866

39 libdyld.dylib 0x00007fff6b5d2cc9 start + 1

40 libdyld.dylib 0x000000000000008d start + 18446603338714895301

error: Abort trap: 6 (in target 'VCore' from project 'VCore')

I will file it as a compiler error on bugs.swift.org... I assume that is correct.

https://bugs.swift.org/browse/SR-13884