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

A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x290... while deleting object from Realm. #1982

Closed
MateuszGajowski opened this issue Dec 21, 2015 · 18 comments
Assignees
Labels

Comments

@MateuszGajowski
Copy link

I have A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x290 in tid 18295 (app) while deleting object from RealmList in RecyclerView. It doesn't matter if I do this async or not.

@NikoYuwono
Copy link

What version of realm are you using? And what function did you call?

@cmelchior
Copy link
Contributor

Hi @Mateuszg7
Please see https://github.com/realm/realm-java/blob/master/CONTRIBUTING.md#filing-issues when creating bugs for us to help you effectively.

@MateuszGajowski
Copy link
Author

I was using Realm version 0.84.1 and I checked it too on 0.86.
I tried two methods:

  1. Some RealmList dogs...
    dogs.remove(position);
    2, dogs.get(position).removeFromRealm();
    Of course all in transaction.

In other place I'm checking size with query related to this deleted object. So I think it might be somehow related to #1945

@kneth
Copy link
Contributor

kneth commented Dec 28, 2015

@Mateuszg7 Can you share a code snippet?

@michbas796
Copy link

I have found workaround. Code snippet from my application:

realm.removeAllChangeListeners();
realm.beginTransaction();
listItems.remove(position);
realm.commitTransaction();
adapter.notifyItemRemoved(position);

In my case SIGSEGV occures if I switch to another activity, then return to previous and remove item from RealmResults. Before displaying the second activity item is removed correctly.

I use RealmRecyclerView and RealmBasedRecyclerViewAdapter from https://github.com/thorbenprimke/realm-recyclerview. Realm version: 0.86.1

@kneth
Copy link
Contributor

kneth commented Jan 5, 2016

@michbas796 I noticed that you mention RealmCyclerView so I have created an issue there in order to get some insight on the interaction between the two components.

@thorbenprimke
Copy link

Yea, the workout isn't good. You should be able to just remove from the realm and the RealmRecyclerView will update automatically (via change listener) if it's enabled.

@michbas796, I generally delete directly from the Realm (via re-querying the item by id and then calling removeFromRealm) but deleting from the realmResults directly should work as well.

@kneth, I'm calling realmResults.size() in a few places in the adapter when the RealmChangeListener is triggered. Not sure if that could be the cause based on #1945.

@michbas796, since you mentioned this only happens after switching between activities and that removing the change listener resolves it, there could be a bug there (on the RealmRecyclerView side).
Any way you could share your screen/activity class(es) via gist?

@kneth kneth added the Pending label Jan 6, 2016
@michbas796
Copy link

Thanks for Your replies.

@thorbenprimke
My code is public: https://github.com/michbas796/PUM/tree/master/app/src/main/java/pl/polsl/pum2/shoppingapp/gui

Mentioned activities are MainActivity and ShoppingListActivity. I switch to ShoppingListActivity is from AllShoppingListsFragment. Sorry for Polish commit descriptions. This is just simple university project (not completed yet) created to pass mobile programming course.

Another issue in RealmRecyclerView or RealmBasedRecyclerViewAdapter is that when I use async query (findAllAsync method) recycler view is empty after swich to other fragment and return to previous. It is populated again only after recreating activity for example by rotating screen.

@kneth kneth removed the Pending label Jan 6, 2016
@kneth
Copy link
Contributor

kneth commented Jan 12, 2016

@maciejwitowski From your repository it looks like you have upgraded to Realm 0.87.1. Both 0.86.1 and 0.87.1 had a few fixes for async.

Can you give us a clear path on how to obtain the crash?

@kneth kneth added the Pending label Jan 12, 2016
@ghost
Copy link

ghost commented Jan 12, 2016

@kneth I think you meant @michbas796 , not me :)

@thorbenprimke
Copy link

@kneth - I can repro the crash when navigating between the two screen, AllShoppingListsFragment and ShoppingListFragment, and do a delete once the AllShoppingListsFragment is displayed again.
I tracked it down to the RealmBasedRecyclerViewAdapter subscribing to change events but not unsubscribing. Then when the delete happens the event is received for a RealmResult that is not longer valid (so I assume). Thus the RealmBasedRecyclerViewAdapter needs a method that can be called to clean things up when an activity/fragment is destroyed/detached.

@kneth
Copy link
Contributor

kneth commented Jan 13, 2016

@maciejwitowski Damn autocompletion - sorry.

@kneth
Copy link
Contributor

kneth commented Jan 13, 2016

@thorbenprimke Thanks for the update.

@beeender
Copy link
Contributor

I checked the code https://github.com/michbas796/PUM/tree/master/app/src/main/java/pl/polsl/pum2/shoppingapp/gui , I think it would be the same issue with #1945

ShoppingList shoppingList = realm.where(ShoppingList.class).equalTo("name", listName).findFirst();
RealmResults<ShoppingListItem> itemsWithPrice = shoppingList.getItems().where().greaterThan("price", 0.0).equalTo("isBought", true).findAll();

The RealmResults is built on another RealmResults.

But let keep this issue open until we verify it.

@michbas796
Copy link

I have changed code in my repository https://github.com/michbas796/PUM/tree/master/app/src/main/java/pl/polsl/pum2/shoppingapp/gui. If you still want to use old version for testing please switch to Test branch.

@thorbenprimke
Copy link

@michbas796 - I have added a close method to the RealmBasedRecyclerViewAdapter. If you add this to your onStop methods before the realm.close() it will fix the crash.
Once that's done, you can change your removeItem method back to

        realm.beginTransaction();
        listItems.remove(position);
        realm.commitTransaction();

Also you need to update the dependency to

compile 'com.github.thorbenprimke:realm-recyclerview:0.9.13'

@michbas796
Copy link

@thorbenprimke
Thanks.

@kneth
Copy link
Contributor

kneth commented Jan 18, 2016

@thorbenprimke Thanks for the fix.
@michbas796 I'll close the issue. Don't hesitate to reopen it or create a new issue if you experience problems.

@kneth kneth closed this as completed Jan 18, 2016
@kneth kneth removed the P1 label Jan 18, 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

7 participants