Open dmho418 opened 6 years ago
Provide a crash log. This is only your suspicion what is the problem and it looks like you are wrong.
XCode 9.1 Log:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.facebook.socketrocket.macos 0x0000000104998470 __36-[SRWebSocket _HTTPHeadersDidFinish]_block_invoke + 80 (SRWebSocket.m:409)
1 com.facebook.socketrocket.macos 0x00000001049abfcb __45-[SRDelegateController performDelegateBlock:]_block_invoke.47 + 59 (SRDelegateController.m:123)
Standalone repro code (supposing there is a service at ws://localhost:54321)
#import "AppDelegate.h"
#import <SocketRocket/SocketRocket.h>
@interface Service: NSObject<SRWebSocketDelegate>
@property SRWebSocket* webSocket;
- (void)webSocketDidOpen:(SRWebSocket *)webSocket;
- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessageWithString:(NSString *)string;
- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error;
- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(nullable NSString *)reason wasClean:(BOOL)wasClean;
@end
@implementation Service
- (id)init
{
if (self = [super init]) {
_webSocket = [[SRWebSocket alloc] initWithURL:[NSURL URLWithString:@"ws://localhost:54321"]];
_webSocket.delegate = self;
[_webSocket open];
}
return self;
}
- (void)webSocketDidOpen:(SRWebSocket *)webSocket{}
- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessageWithString:(NSString *)string{}
- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error{}
- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(nullable NSString *)reason wasClean:(BOOL)wasClean{}
@end
@interface AppDelegate ()
@property Service * service;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
_service = [[Service alloc] init];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {}
@end
Same here on iOS 9.3.5, crash with:
Thread 1: EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe
420 if (availableMethods.didOpen) { 421 [delegate webSocketDidOpen:self]; 422 }
818 if (availableMethods.didReceiveMessageWithString) { 819 [delegate webSocket:self didReceiveMessageWithString:string]; 820 }
I'm also seeing a crash on iOS 9.3.5.
Tested with: Xcode Version 9.3 (9E145) Xcode Version 9.2 (9C40b)
Thread 1: EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe)
[self.delegateController performDelegateBlock:^(id<SRWebSocketDelegate> _Nullable delegate, SRDelegateAvailableMethods availableMethods) {
if (availableMethods.didOpen) { // <-- Crashes here
[delegate webSocketDidOpen:self];
}
}];
This PR appears relevant: https://github.com/facebook/SocketRocket/pull/530
Yup. Good catch, folks! Just commented on the PR with a suggestion on how to improve it. Let’s see if it gets updated and if yes - will merge.
This bit field is crashing in XCode9. Maybe something to do with the size of BOOL?
https://github.com/facebook/SocketRocket/blob/28035e1a98a427853e4038ff1b70479fa8374cfa/SocketRocket/Internal/Delegate/SRDelegateController.h#L16