Skip to content

Sometimes, setting PFObject subclass properties causes unrecognised selector crash #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lbevilacqua opened this issue Aug 24, 2015 · 5 comments

Comments

@lbevilacqua
Copy link

Since 1.8.0, I'm experiencing random unrecognised selector crashes in our app.
I don't know why (haven't given a look at the SDK source code), when I write object.property = something, at runtime this gets translated to -[object _original_setProperty: something].
I managed to solve one occurrence of this issue by using the notation object [@"property"] = something but it keeps showing up with other property names.
I inspected the objects before the crash and found no clues or strange values.
I'm sharing with you two fabric stack traces, hope it helps figuring out what's wrong.

http://crashes.to/s/3daef3b256b
http://crashes.to/s/b12cbbb567d

@richardjrossiii
Copy link
Contributor

Thanks for the report. It does not appear that parse is in this stack trace at all.

Are you using KVO with PFObject instances? That is currently unsupported and may be causing the issues you are seeing. KVO automatically 'swizzles' out the class of the object you begin observing on, which would wreak havoc on our PFObject subclassing code as it stands. In the future, we would like to add KVO support, but it is not currently on our roadmap.

If you're not using KVO, can you post the header for your PFObject subclass? There may be something
funny going on with your inheritance chain that we forgot to support.

@lbevilacqua
Copy link
Author

Thank you for the fast reply Richard,

I’m using KVO, but not on keys defined on the Parse model, only on local ivars.
The unrecognised selector exception happens when setting a Parse model key (below are included all the keys in the model).

@interface BuggUser : PFUser
@property (nonatomic, copy) NSString * firstName;
@property (nonatomic, copy) NSString * lastName;
@property (nonatomic, copy) NSString * facebookId;
@property (nonatomic, strong) BuggUserPicture * picture;
@property (nonatomic, strong) NSDictionary * preferences;
@property (nonatomic, strong) NSDate * lastFetchAt;
@property (nonatomic, strong) NSDate * notificationsReadAt;
@end

@implementation BuggUser
@dynamic facebookId, firstName, lastFetchAt, lastName, notificationsReadAt, picture, preferences;
// other methods
@end

@richardjrossiii
Copy link
Contributor

Your subclass definition appears to be correct. I assume that you have properly registered your PFObject subclass, correct?

Is it possible that you have another dangling pointer/stack corruption somewhere which is causing these issues? I'd recommend profiling your app with all of the available memory debugging options, including:

  • guard malloc
  • guard edges
  • malloc scribble
  • zombies

And see if anything pops up.

The more I look at your stack trace, the less convinced I am that this is a Parse issue. For example, you seem to be directly invoking the internal method _NSSetObjectValueAndNotify, which is internal to Foundation and should never be invoked manually.

@lbevilacqua
Copy link
Author

Yes, I have properly registered the subclass.
I tried profiling the app with the leaks instrument and then running with the memory debugging options, and found no clues.
I think it is definitely KVO-related, as I found and removed an observer on the keyPaths that triggered the crash, and the crash doesn't occur anymore.
I still can't figure out why this issue began showing only when upgrading to 1.8.x...

@richardjrossiii
Copy link
Contributor

The only thing I can think of is that PFObject subclass management was refactored for the 1.8 release. No functionality changes were made, but perhaps an edge case with KVO is no longer handled exactly the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants