WrathChaos/StompClientLib

Error when calling delegate

Rodolfocartas opened this issue · 3 comments

I keep getting this error. I thought the problem was that delegate was getting deallocated before the library gets to call the delegate method. I moved the delegate to a singleton object and the error is still surfacing. The problem seems to be related to a cast, but I haven't so far found it.

Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0x182e6d348 __pthread_kill + 8
1  libsystem_pthread.dylib        0x182f81354 pthread_kill$VARIANT$mp + 396
2  libsystem_c.dylib              0x182ddcfd8 abort + 140
3  libswiftCore.dylib             0x105b0162c swift_vasprintf(char**, char const*, char*) + 54
4  libswiftCore.dylib             0x105af71f0 swift::swift_dynamicCastFailure(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, char const*) + 74
5  libswiftCore.dylib             0x105af7268 swift_dynamicCastClass + 118
6  libswiftCore.dylib             0x105b2f89c swift_dynamicCastForeignClass + 82
7  libswiftCore.dylib             0x105afad04 _dynamicCastClassToValueViaObjCBridgeable(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, (anonymous namespace)::_ObjectiveCBridgeableWitnessTable const*, swift::DynamicCastFlags) + 92
8  libswiftCore.dylib             0x105af8fe8 swift_dynamicCast + 568
9  StompClientLib                 0x1055a582c specialized StompClientLib.(webSocket(SRWebSocket!, didFailWithError : Error!) -> ()).(closure #1) (StompClientLib.swift:183)
10 StompClientLib                 0x1055a7af4 partial apply for StompClientLib.(webSocket(SRWebSocket!, didFailWithError : Error!) -> ()).(closure #1) (StompClientLib.swift)
11 StompClientLib                 0x10559ce64 thunk (StompClientLib.swift)
12 libdispatch.dylib              0x182cd9088 _dispatch_call_block_and_release + 24
13 libdispatch.dylib              0x182cd9048 _dispatch_client_callout + 16
14 libdispatch.dylib              0x182ce5b74 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016
15 CoreFoundation                 0x1832fbf20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
16 CoreFoundation                 0x1832f9afc __CFRunLoopRun + 2012
17 CoreFoundation                 0x18321a2d8 CFRunLoopRunSpecific + 436
18 GraphicsServices               0x1850abf84 GSEventRunModal + 100
19 UIKit                          0x18c7c7880 UIApplicationMain + 208
20 pingogps                       0x1002c5794 main (AppDelegate.swift:24)
21 libdyld.dylib                  0x182d3e56c start + 4

Hello, can you share your code? Also did you call every delegate function ?

I checked the code. The library is casting an Error into a String thus causing the crash. The problem occurs in StompClientLib.swift:183.

Thank you for fixing the code :) I'm going to make a new version with your correction