Skip to content

[SR-10200] NSForwarding: warning: object 0x102408108 of class 'Module.NonGenericFinalSwiftClass' does not implement methodSignatureForSelector: -- trouble ahead #52600

@DevAndArtist

Description

@DevAndArtist
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:

#&#8203;0  0x00000001bf362ec8 in _class_initialize ()
#&#8203;1  0x00000001bf36c8f8 in lookUpImpOrForward ()
#&#8203;2  0x00000001bf379098 in _objc_msgSend_uncached ()
#&#8203;3  0x00000001c01967dc in ___forwarding___ ()
#&#8203;4  0x00000001c019848c in _CF_forwarding_prep_0 ()
#&#8203;5  0x00000001bf35d024 in CALLING_SOME_+initialize_METHOD ()
#&#8203;6  0x00000001bf362f84 in _class_initialize ()
#&#8203;7  0x00000001bf36c8f8 in lookUpImpOrForward ()
#&#8203;8  0x00000001bf379098 in _objc_msgSend_uncached ()
#&#8203;9  0x00000001029d6b4c in swift_dynamicCastObjCClassMetatype ()
#&#8203;10 0x000000010298ab30 in swift_dynamicCastMetatypeImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*) ()
#&#8203;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)>) ()
#&#8203;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 ()
#&#8203;13 0x00000001029aaac4 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#&#8203;14 0x00000001029aa100 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#&#8203;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)>) ()
#&#8203;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)>) ()
#&#8203;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)>) ()
#&#8203;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)>) ()
#&#8203;19 0x000000010299f114 in getSuperclassMetadata(swift::TargetClassMetadata<swift::InProcess>*, bool) ()
#&#8203;20 0x0000000102999df4 in _swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) ()
#&#8203;21 0x000000010237b988 in type metadata completion function for GenericCoreClass ()
#&#8203;22 0x00000001029a0e24 in swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#&#8203;23 0x0000000102998168 in swift_getGenericMetadata ()
#&#8203;24 0x000000010237a58c in type metadata accessor for GenericCoreClass ()
#&#8203;25 0x000000010230173c in type metadata accessor for GenericCoreClass<InterfaceAsStruct> ()
#&#8203;26 0x00000001023c29f0 in GenericCoreClass.start() at file_where_code_is_executed.swift:16
#&#8203;27 0x000000010237b9d4 in partial apply for GenericCoreClass.start() ()
#&#8203;28 0x0000000102337174 in thunk for @escaping @callee_guaranteed () -> () ()
#&#8203;29 0x00000001032b7824 in _dispatch_call_block_and_release ()
#&#8203;30 0x00000001032b8dc8 in _dispatch_client_callout ()
#&#8203;31 0x00000001032c0e6c in _dispatch_lane_serial_drain ()
#&#8203;32 0x00000001032c1b60 in _dispatch_lane_invoke ()
#&#8203;33 0x00000001032cbbfc in _dispatch_workloop_worker_thread ()
#&#8203;34 0x00000001bfdad0dc in _pthread_wqthread ()
#&#8203;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
      ...
    }
  }
}
#&#8203;0  0x00000001dbf676cc in initObjCClass(swift::TargetClassMetadata<swift::InProcess>*, unsigned long, swift::TypeLayout const* const*, unsigned long*) ()
#&#8203;1  0x00000001dbf627e0 in _swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) ()
#&#8203;2  0x000000010299531c in type metadata completion function for DrivingUnleashedStorage ()
#&#8203;3  0x00000001dbf6a1c4 in swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#&#8203;4  0x00000001dbf65d10 in swift::resumeMetadataCompletion(swift::MetadataCompletionQueueEntry*) ()
#&#8203;5  0x00000001dbf6a550 in swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#&#8203;6  0x00000001dbf60820 in swift_getSingletonMetadata ()
#&#8203;7  0x00000001029788d0 in type metadata accessor for UnleashedStorage ()
#&#8203;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 ()
#&#8203;9  0x00000001dbf72c94 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#&#8203;10 0x00000001dbf72428 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#&#8203;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)>) ()
#&#8203;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)>) ()
#&#8203;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)>) ()
#&#8203;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)>) ()
#&#8203;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*) ()
#&#8203;16 0x00000001dbf65340 in swift_getAssociatedTypeWitness ()
#&#8203;17 0x00000001dbf730a0 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#&#8203;18 0x00000001dbf72428 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#&#8203;19 0x00000001dbf7297c in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#&#8203;20 0x00000001dbf72428 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#&#8203;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)>) ()
#&#8203;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)>) ()
#&#8203;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)>) ()
#&#8203;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)>) ()
#&#8203;25 0x00000001dbf6743c in getSuperclassMetadata(swift::TargetClassMetadata<swift::InProcess>*, bool) ()
#&#8203;26 0x00000001dbf62088 in _swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) ()
#&#8203;27 0x0000000102a214b0 in type metadata completion function for OtherGenericCoreClass ()
#&#8203;28 0x00000001dbf69164 in swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#&#8203;29 0x00000001dbf603f8 in swift_getGenericMetadata ()
#&#8203;30 0x0000000102a18424 in type metadata accessor for OtherGenericCoreClass ()
#&#8203;31 0x00000001029ec0b8 in type metadata accessor for OtherGenericCoreClass<InterfaceAsStruct> ()
#&#8203;32 0x0000000102a18b00 in OtherGenericCoreClass.start() at FILE_NAME.swift:56
#&#8203;33 0x0000000102a236e0 in partial apply for OtherGenericCoreClass.start() ()
#&#8203;34 0x00000001029a7174 in thunk for @escaping @callee_guaranteed () -> () ()
#&#8203;35 0x0000000102d576f0 in _dispatch_call_block_and_release ()
#&#8203;36 0x0000000102d58c74 in _dispatch_client_callout ()
#&#8203;37 0x0000000102d60bf4 in _dispatch_lane_serial_drain ()
#&#8203;38 0x0000000102d618b4 in _dispatch_lane_invoke ()
#&#8203;39 0x0000000102d6b77c in _dispatch_workloop_worker_thread ()
#&#8203;40 0x00000001ae631114 in _pthread_wqthread ()
#&#8203;41 0x00000001ae633cd4 in start_wqthread ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions