-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution
Description
| Previous ID | SR-10200 |
| Radar | None |
| Original Reporter | @DevAndArtist |
| Type | Bug |
Environment
Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, RunTimeCrash |
| Assignee | None |
| Priority | Medium |
md5: 1b7b3667a0b982abf12099be628faeff
Issue Description:
I cannot post the exact code, this issue started top pop up randomly with the Swift 5 compiler in Swift 4.2 mode. It worked perfectly fine with the old compiler.
extension GenericCoreClass {
func start() {
// Ensure proper synchronization.
preconditionIsOnQueue()
switch self {
case let core as GenericCoreClass<InterfaceAsStruct>: // crashes here
...
default:
break
}
}
}Part of the stack trace:
#​0 0x00000001bf362ec8 in _class_initialize ()
#​1 0x00000001bf36c8f8 in lookUpImpOrForward ()
#​2 0x00000001bf379098 in _objc_msgSend_uncached ()
#​3 0x00000001c01967dc in ___forwarding___ ()
#​4 0x00000001c019848c in _CF_forwarding_prep_0 ()
#​5 0x00000001bf35d024 in CALLING_SOME_+initialize_METHOD ()
#​6 0x00000001bf362f84 in _class_initialize ()
#​7 0x00000001bf36c8f8 in lookUpImpOrForward ()
#​8 0x00000001bf379098 in _objc_msgSend_uncached ()
#​9 0x00000001029d6b4c in swift_dynamicCastObjCClassMetatype ()
#​10 0x000000010298ab30 in swift_dynamicCastMetatypeImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*) ()
#​11 0x00000001029ae394 in swift::_checkGenericRequirements(llvm::ArrayRef<swift::TargetGenericRequirementDescriptor<swift::InProcess> >, std::__1::vector<void const*, std::__1::allocator<void const*> >&, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​12 0x00000001029ab410 in (anonymous namespace)::DecodedMetadataBuilder::createBoundGenericType(swift::TargetContextDescriptor<swift::InProcess> const*, llvm::ArrayRef<swift::TargetMetadata<swift::InProcess> const*>, swift::TargetMetadata<swift::InProcess> const*) const ()
#​13 0x00000001029aaac4 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#​14 0x00000001029aa100 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#​15 0x00000001029a99e8 in swift_getTypeByMangledNodeImpl(swift::MetadataRequest, swift::Demangle::Demangler&, swift::Demangle::Node*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​16 0x00000001029a97a8 in swift::swift_getTypeByMangledNode(swift::MetadataRequest, swift::Demangle::Demangler&, swift::Demangle::Node*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​17 0x00000001029a9d18 in swift_getTypeByMangledNameImpl(swift::MetadataRequest, llvm::StringRef, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​18 0x00000001029a8110 in swift::swift_getTypeByMangledName(swift::MetadataRequest, llvm::StringRef, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​19 0x000000010299f114 in getSuperclassMetadata(swift::TargetClassMetadata<swift::InProcess>*, bool) ()
#​20 0x0000000102999df4 in _swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) ()
#​21 0x000000010237b988 in type metadata completion function for GenericCoreClass ()
#​22 0x00000001029a0e24 in swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#​23 0x0000000102998168 in swift_getGenericMetadata ()
#​24 0x000000010237a58c in type metadata accessor for GenericCoreClass ()
#​25 0x000000010230173c in type metadata accessor for GenericCoreClass<InterfaceAsStruct> ()
#​26 0x00000001023c29f0 in GenericCoreClass.start() at file_where_code_is_executed.swift:16
#​27 0x000000010237b9d4 in partial apply for GenericCoreClass.start() ()
#​28 0x0000000102337174 in thunk for @escaping @callee_guaranteed () -> () ()
#​29 0x00000001032b7824 in _dispatch_call_block_and_release ()
#​30 0x00000001032b8dc8 in _dispatch_client_callout ()
#​31 0x00000001032c0e6c in _dispatch_lane_serial_drain ()
#​32 0x00000001032c1b60 in _dispatch_lane_invoke ()
#​33 0x00000001032cbbfc in _dispatch_workloop_worker_thread ()
#​34 0x00000001bfdad0dc in _pthread_wqthread ()
#​35 0x00000001bfdafcec in start_wqthread ()The code is running on a custom serial queue.
Edit:
New similar crash on a similar subtype:
extension OtherGenericCoreClass {
func start() {
// Ensure sync.
preconditionIsOnQueue()
if let core = self as? OtherGenericCoreClass<InterfaceAsStruct> { // crashes here
...
}
}
}#​0 0x00000001dbf676cc in initObjCClass(swift::TargetClassMetadata<swift::InProcess>*, unsigned long, swift::TypeLayout const* const*, unsigned long*) ()
#​1 0x00000001dbf627e0 in _swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) ()
#​2 0x000000010299531c in type metadata completion function for DrivingUnleashedStorage ()
#​3 0x00000001dbf6a1c4 in swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#​4 0x00000001dbf65d10 in swift::resumeMetadataCompletion(swift::MetadataCompletionQueueEntry*) ()
#​5 0x00000001dbf6a550 in swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#​6 0x00000001dbf60820 in swift_getSingletonMetadata ()
#​7 0x00000001029788d0 in type metadata accessor for UnleashedStorage ()
#​8 0x00000001dbf73808 in (anonymous namespace)::DecodedMetadataBuilder::createBoundGenericType(swift::TargetContextDescriptor<swift::InProcess> const*, llvm::ArrayRef<swift::TargetMetadata<swift::InProcess> const*>, swift::TargetMetadata<swift::InProcess> const*) const ()
#​9 0x00000001dbf72c94 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#​10 0x00000001dbf72428 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#​11 0x00000001dbf71d10 in swift_getTypeByMangledNodeImpl(swift::MetadataRequest, swift::Demangle::Demangler&, swift::Demangle::Node*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​12 0x00000001dbf71ad0 in swift::swift_getTypeByMangledNode(swift::MetadataRequest, swift::Demangle::Demangler&, swift::Demangle::Node*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​13 0x00000001dbf72044 in swift_getTypeByMangledNameImpl(swift::MetadataRequest, llvm::StringRef, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​14 0x00000001dbf70450 in swift::swift_getTypeByMangledName(swift::MetadataRequest, llvm::StringRef, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​15 0x00000001dbf66d84 in swift_getAssociatedTypeWitnessSlowImpl(swift::MetadataRequest, swift::TargetWitnessTable<swift::InProcess>*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*) ()
#​16 0x00000001dbf65340 in swift_getAssociatedTypeWitness ()
#​17 0x00000001dbf730a0 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#​18 0x00000001dbf72428 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#​19 0x00000001dbf7297c in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#​20 0x00000001dbf72428 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#​21 0x00000001dbf71d10 in swift_getTypeByMangledNodeImpl(swift::MetadataRequest, swift::Demangle::Demangler&, swift::Demangle::Node*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​22 0x00000001dbf71ad0 in swift::swift_getTypeByMangledNode(swift::MetadataRequest, swift::Demangle::Demangler&, swift::Demangle::Node*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​23 0x00000001dbf72044 in swift_getTypeByMangledNameImpl(swift::MetadataRequest, llvm::StringRef, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​24 0x00000001dbf70450 in swift::swift_getTypeByMangledName(swift::MetadataRequest, llvm::StringRef, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) ()
#​25 0x00000001dbf6743c in getSuperclassMetadata(swift::TargetClassMetadata<swift::InProcess>*, bool) ()
#​26 0x00000001dbf62088 in _swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) ()
#​27 0x0000000102a214b0 in type metadata completion function for OtherGenericCoreClass ()
#​28 0x00000001dbf69164 in swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#​29 0x00000001dbf603f8 in swift_getGenericMetadata ()
#​30 0x0000000102a18424 in type metadata accessor for OtherGenericCoreClass ()
#​31 0x00000001029ec0b8 in type metadata accessor for OtherGenericCoreClass<InterfaceAsStruct> ()
#​32 0x0000000102a18b00 in OtherGenericCoreClass.start() at FILE_NAME.swift:56
#​33 0x0000000102a236e0 in partial apply for OtherGenericCoreClass.start() ()
#​34 0x00000001029a7174 in thunk for @escaping @callee_guaranteed () -> () ()
#​35 0x0000000102d576f0 in _dispatch_call_block_and_release ()
#​36 0x0000000102d58c74 in _dispatch_client_callout ()
#​37 0x0000000102d60bf4 in _dispatch_lane_serial_drain ()
#​38 0x0000000102d618b4 in _dispatch_lane_invoke ()
#​39 0x0000000102d6b77c in _dispatch_workloop_worker_thread ()
#​40 0x00000001ae631114 in _pthread_wqthread ()
#​41 0x00000001ae633cd4 in start_wqthread ()Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution