Skip to content
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

Crash when accessing obj by its int primary key (0.91.3 -> 0.93.0) #2018

Closed
rsahara opened this issue May 28, 2015 · 2 comments
Closed

Crash when accessing obj by its int primary key (0.91.3 -> 0.93.0) #2018

rsahara opened this issue May 28, 2015 · 2 comments
Labels

Comments

@rsahara
Copy link

rsahara commented May 28, 2015

I just tried to update from 0.91.3 to 0.93.0 and encountered the following crash.
Is there something wrong with my code?

The view looks like this:

  • A UICollectionView is holding an NSArray of RLMObject representing products.
  • Each cell shows a product with its brand name. (RLMObject of brand, with brandId as primary key)
    After scrolling a few pages of the UICollectionView, the app crashes when accessing the brand model.

Call stack

Thread 1Queue : com.apple.main-thread (serial)
#0  0x0000000108cf2cf6 in unsigned long realm::Array::index_string<(realm::IndexMethod)0, realm::StringData>(realm::StringData, realm::Column&, unsigned long&, void*, realm::StringData (*)(void*, unsigned long, char*)) const ()
#1  0x0000000108ceef93 in realm::Array::IndexStringFindFirst(realm::StringData, void*, realm::StringData (*)(void*, unsigned long, char*)) const ()
#2  0x0000000108d754f4 in realm::Column::find_first(long long, unsigned long, unsigned long) const ()
#3  0x0000000108cb0190 in RLMGetObject at /Users/realm/workspace/objc_ios/tightdb_objc/Realm/RLMObjectStore.mm:623
#4  0x0000000108ca6833 in +[RLMObject objectInRealm:forPrimaryKey:] at /Users/realm/workspace/objc_ios/tightdb_objc/Realm/RLMObject.mm:145
#5  0x00000001089f0f08 in -[ModelManager brandById:] at /Users/rsahara/.../App/Model/ModelManager.m:1458
#6  0x000000010896b8bf in -[ProductListViewController collectionView:cellForItemAtIndexPath:] at /Users/rsahara/.../App/UI/Common/ProductList/ProductListViewController.m:593
#7  0x000000010ae8cfab in -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] ()
#8  0x000000010ae8e6e4 in -[UICollectionView _updateVisibleCellsNow:] ()
#9  0x000000010ae92391 in -[UICollectionView layoutSubviews] ()
#10 0x000000010a8d71c3 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#11 0x000000010c333c58 in -[CALayer layoutSublayers] ()
#12 0x000000010c32887e in CA::Layer::layout_if_needed(CA::Transaction*) ()
#13 0x000000010c3286ee in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#14 0x000000010c29636e in CA::Context::commit_transaction(CA::Transaction*) ()
#15 0x000000010c297482 in CA::Transaction::commit() ()
#16 0x000000010c297aed in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) ()
#17 0x000000010cbae507 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#18 0x000000010cbae460 in __CFRunLoopDoObservers ()
#19 0x000000010cba4293 in __CFRunLoopRun ()
#20 0x000000010cba3bc6 in CFRunLoopRunSpecific ()
#21 0x000000010e975a58 in GSEventRunModal ()
#22 0x000000010a85d580 in UIApplicationMain ()
#23 0x0000000108a3b3d3 in main at /Users/rsahara/.../main.m:14
#24 0x000000010d2ea145 in start ()

Code calling RLMObject

-(ModelBrand*)brandById:(int)brandId
{
    return [ModelBrand objectInRealm:_cacheDb
                       forPrimaryKey:[NSNumber numberWithInt:brandId]];
}

Model

@interface ModelBrand : RLMObject

@property NSDate*       modelUpdate;
@property int           brandId; // key
@property NSString*     brandName;
@property NSString*     brandNameIndex;
@property int           brandType;
@property int           status;
@property int           siteId;
@property BOOL          open;
@property BOOL          recommended;

@end

// impl

+ (NSString*)primaryKey
{
    return @"brandId";
}

+ (NSDictionary *)defaultPropertyValues
{
    return @{
             @"modelUpdate":[NSDate date],
             @"brandId":@0,
             @"brandNameIndex":@"",
             };
}

Thanks.

@jpsim
Copy link
Contributor

jpsim commented May 29, 2015

This should now be fixed with #2024. We intend to release a new version including the fix shortly.

@rsahara
Copy link
Author

rsahara commented May 31, 2015

Thanks! Will check again once released.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants