zwopple / PocketSocket

Objective-C websocket library for building things that work in realtime on iOS and OS X.
Other
414 stars 129 forks source link

dispatch_async (bad access) #17

Closed LexTheGreat closed 10 years ago

LexTheGreat commented 10 years ago

Hello, I have a bad access error for dispatch_async in 'executeWork'

Tracing it back to where the execute in '(void)open'

- (void)open {
    [self executeWork:^{
        if(_opened || _readyState != PSWebSocketReadyStateConnecting) {
            [NSException raise:@"Invalid State" format:@"You cannot open a PSWebSocket more than once."];
            return;
        }

        _opened = YES;

        // connect
        [self connect];
    }];
}

............
- (void)executeWork:(void (^)(void))work {
    NSParameterAssert(work);
    dispatch_async(_workQueue, work); <---- Error here
}

Is there any way to fix this? Not really sure why this happens...

Xcode Beta 6, Building for IOS 7/8 Using swift with Object-C

robertjpayne commented 10 years ago

Is this still happening for you now? Is it a reproducible as a sample project would be extremely helpful.

LexTheGreat commented 10 years ago

Yes, Once I get to my development computer I will upload a sample.

LexTheGreat commented 10 years ago

https://dl.dropboxusercontent.com/u/42959738/Files/Eclipse%20IOS%20Server.zip

Here is the little server I made with the error popping up

robertjpayne commented 10 years ago

@LexTheGreat the sample project here is a OS X target? Also are you still running 10.9 or 10.10? Just want to make sure I get everything setup identically so I can reproduce it!

LexTheGreat commented 10 years ago

Yea server I was using with OS X, 10.9.4

Edit: Although I just tried to build to reproduce and xcode beta 6 could build on 10.9, not the regular xcode 6 going to update to Yosemite and reproduce (Dependency problems)

LexTheGreat commented 10 years ago

Ok so I found out where it was stoping it,

- (void)dealloc {
    [self executeWorkAndWait:^{
        [self disconnect:YES]; <- This is the work that stops the application
    }];
}

If I comment it out it does not crash

LexTheGreat commented 10 years ago

I figured out the problem, I forgot to set delegate (Silly me :S)