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

Detect invalid RealmResults #1945

Closed
kneth opened this issue Dec 16, 2015 · 1 comment
Closed

Detect invalid RealmResults #1945

kneth opened this issue Dec 16, 2015 · 1 comment
Assignees
Labels

Comments

@kneth
Copy link
Contributor

kneth commented Dec 16, 2015

The following code might lead to a native crash:

realm.beginTransaction();
RealmResults<Owner> owners = realm.allObjects(Owner.class);
RealmResults<Dog> dogs = owners.first().where().equalTo("dogs.name", "Fido").findAll();
owners.clear();
long nDogs = dogs.size(); // crash here
realm.commitTransaction();

The reason is that Realm's storage engine doesn't invalidate dogs after owners.clear(). Once it does, an exception should be thrown at dogs.size().

See also realm/realm-core#1413

@kneth kneth added T-Bug P1 Blocked This issue is blocked by another issue labels Dec 16, 2015
@beeender beeender self-assigned this Jan 19, 2016
beeender added a commit that referenced this issue Jan 22, 2016
* When the original RealmList is deleted, for most methods of
  RealmResults should just work without crash by just treat it like an
  empty RealmResults.
* RealmResults.where() throws IllegalStateExecption in this case.
* RealmResults.isValid() return false in this case.

This is a temp fix, check realm/realm-core#1434
for more details.

Close #1945
beeender added a commit that referenced this issue Jan 22, 2016
* When the original RealmList is deleted, for most methods of
  RealmResults should just work without crash by just treat it like an
  empty RealmResults.
* RealmResults.where() throws IllegalStateExecption in this case.
* RealmResults.isValid() returns false in this case.

This is a temp fix, check realm/realm-core#1434
for more details.

Close #1945
beeender added a commit that referenced this issue Jan 25, 2016
* When the original RealmList is deleted, for most methods of
  RealmResults should just work without crash by just treat it like an
  empty RealmResults.
* RealmResults.where() throws IllegalStateExecption in this case.
* RealmResults.isValid() returns false in this case.

This is a temp fix, check realm/realm-core#1434
for more details.

Close #1945
beeender added a commit that referenced this issue Jan 25, 2016
* When the original RealmList is deleted, for most methods of
  RealmResults should just work without crash by just treat it like an
  empty RealmResults.
* RealmResults.where() throws IllegalStateExecption in this case.
* RealmResults.isValid() returns false in this case.

This is a temp fix, check realm/realm-core#1434
for more details.

Close #1945
beeender added a commit that referenced this issue Jan 25, 2016
* When the original RealmList is deleted, for most methods of
  RealmResults should just work without crash by just treat it like an
  empty RealmResults.
* RealmResults.where() throws IllegalStateExecption in this case.
* RealmResults.isValid() returns false in this case.

This is a temp fix, check realm/realm-core#1434
for more details.

Close #1945
@kneth kneth removed the Blocked This issue is blocked by another issue label Jan 25, 2016
@beeender
Copy link
Contributor

#2133 fixed this.

@beeender beeender removed the P1 label Jan 25, 2016
@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