Gamua / Sparrow-Framework

The Open Source Game Engine for iOS
http://www.sparrow-framework.org
Other
294 stars 83 forks source link

I think the usage of __block inside SPTexture.m may be wrong (causes crash for me) #54

Closed cburtbrown closed 8 years ago

cburtbrown commented 8 years ago

Upon upgrading to Xcode 7.3, I suddenly started to get EXC_BAD_ACCESS crashes when [SPTexture loadFromURL:onComplete:] requests fail. The easiest way to reproduce this error, for me, is to comment out line 384 of SPTexture.m:

// if (!body)
    [NSException raise:SPExceptionOperationFailed
                format:@"couldn't load resource at %@", url.absoluteString];

This simulates the effect of receiving, say, an HTML page of a 404 error instead of image data.

On my system, the app then dies -- most of the time -- with an EXC_BAD_ACCESS. Sometimes it will survive, however, turning on Zombie Objects produces an EXC_BREAKPOINT consistently.

More specifically the variable loadError is deallocated before its usage inside the dispatch_async block. I think this is because the variable is erroneously declared as __block. This stackoverflow question deals with someone else with the same issue.

I took the __block keyword out as the question answer says, and suddenly my crash is gone.

racarone commented 8 years ago

Yup, there's no reason for the __block in that declaration. Thanks for the pull request, will merge it now!