mxcl / PromiseKit

Promises for Swift & ObjC.
MIT License
14.23k stars 1.46k forks source link

catch on crash #1052

Closed pepone closed 5 years ago

pepone commented 5 years ago

I'm using PromiseKit 6.8.4, installed with Carthage Debug build, and getting this crash

#0  0x0000000113ec9770 in swift_conformsToSwiftProtocolImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, llvm::StringRef) ()
#1  0x0000000113ec9598 in swift_conformsToProtocol ()
#2  0x0000000113e9df7a in swift::_conformsToProtocol(swift::OpaqueValue const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptorRef<swift::InProcess>, swift::TargetWitnessTable<swift::InProcess> const**) ()
#3  0x0000000113ec8e58 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)>) ()
#4  0x0000000113ec5743 in (anonymous namespace)::DecodedMetadataBuilder::createBoundGenericType(swift::TargetContextDescriptor<swift::InProcess> const*, llvm::ArrayRef<swift::TargetMetadata<swift::InProcess> const*>, swift::TargetMetadata<swift::InProcess> const*) const ()
#5  0x0000000113ec4da0 in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#6  0x0000000113ec40dc in swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node* const&) ()
#7  0x0000000113ec39de 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)>) ()
#8  0x0000000113ec3806 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)>) ()
#9  0x0000000113ec3e73 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)>) ()
#10 0x0000000113ec2006 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)>) ()
#11 0x0000000113eb6f3f in swift_getAssociatedTypeWitnessSlowImpl(swift::MetadataRequest, swift::TargetWitnessTable<swift::InProcess>*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*) ()
#12 0x0000000113eb5308 in swift_getAssociatedTypeWitness ()
#13 0x0000000113d2c8fe in Sequence.forEach(_:) ()
#14 0x00000001131c7ab6 in EmptyBox.seal(_:) at /Users/jose/Documents/ZeroC/3.7/ice/swift/Carthage/Checkouts/PromiseKit/Sources/Box.swift:51
#15 0x00000001131a87bc in partial apply ()
#16 0x00000001131b3e97 in thunk for @escaping @callee_guaranteed (@in_guaranteed ()) -> () ()
#17 0x00000001131c1f11 in thunk for @escaping @callee_guaranteed (@in_guaranteed ()) -> ()partial apply ()
#18 0x00000001131c175f in closure #1 in CatchMixin.catch(on:flags:policy:_:) at /Users/jose/Documents/ZeroC/3.7/ice/swift/Carthage/Checkouts/PromiseKit/Sources/Catchable.swift:37
#19 0x00000001131c184b in partial apply for closure #1 in CatchMixin.catch(on:flags:policy:_:) ()
#20 0x00000001131d0d81 in Promise.pipe(to:) at /Users/jose/Documents/ZeroC/3.7/ice/swift/Carthage/Checkouts/PromiseKit/Sources/Promise.swift:85
#21 0x00000001131d1459 in protocol witness for Thenable.pipe(to:) in conformance Promise<A> ()
#22 0x00000001131c1159 in CatchMixin.catch(on:flags:policy:_:) at /Users/jose/Documents/ZeroC/3.7/ice/swift/Carthage/Checkouts/PromiseKit/Sources/Catchable.swift:26
#23 0x0000000130866452 in MyClass.iceD_opStringLiterals(incoming:current:) at /Users/jose/Documents/ZeroC/3.7/ice/swift/build/Intermediates/ice.build/Debug-iphonesimulator/IceOperationsAMD iOS.build/DerivedSources/TestAMD.swift:5246

TestAMD.swift:5246 correspond with the .catch call in:

func iceD_opStringLiterals(incoming inS: Ice.Incoming, current: Ice.Current) throws {
    try inS.readEmptyParams()

    firstly {
        opStringLiteralsAsync(current: current)
    }.done(on: nil) { returnValue in
        inS.write { ostr in
            ostr.write(returnValue)
        }
    }.catch(on: nil) { err in
        inS.exception(err)
    }
}

Any ideas what could be causing this crash?

mxcl commented 5 years ago

Thread safety? on(nil:) dispatches to any old queue.

pepone commented 5 years ago

I was doing some fancy stuff with bundle load/unload I think that is triggering a problem with swift_conformsToSwiftProtocolImpl and is unrelated to PromiseKit

mfandre commented 4 years ago

@pepone did you discover? I'm facing the same problem