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

Got crash removing object #5975

Closed
sledderGIT opened this issue Oct 28, 2022 · 5 comments · Fixed by #5993
Closed

Got crash removing object #5975

sledderGIT opened this issue Oct 28, 2022 · 5 comments · Fixed by #5993
Assignees

Comments

@sledderGIT
Copy link

SDK and version

.NET Xamarin
Version: 10.17.0

Observations

Saw it first time

Crash log / stacktrace

Users/runner/work/realm-dotnet/realm-dotnet/wrappers/realm-core/src/realm/array_backlink.cpp:108: [realm-core-12.9.0] Assertion failed: int64_t(value >> 1) == key.value [272, 16]
0 realm-wrappers 0x000000010e548ffc _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1 realm-wrappers 0x000000010e548f01 _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 385
2 realm-wrappers 0x000000010e42de77 ZN5realm4util9terminateIJxxEEEvPKcS3_lDpT + 55
3 realm-wrappers 0x000000010e3e1cb1 _ZN5realm13ArrayBacklink6removeEmNS_6ObjKeyE + 577
4 realm-wrappers 0x000000010e472e92 _ZN5realm3Obj19remove_one_backlinkENS_6ColKeyENS_6ObjKeyE + 354
5 realm-wrappers 0x000000010e4733ce _ZNK5realm3Obj15remove_backlinkENS_6ColKeyENS_7ObjLinkERNS_12CascadeStateE + 302
6 realm-wrappers 0x000000010e41f363 _ZNK5realm10Dictionary16remove_backlinksERNS_12CascadeStateE + 243
7 realm-wrappers 0x000000010e3fe947 _ZZN5realm4util11FunctionRefIFNS_15IteratorControlENS_6ColKeyEEEC1IRZNS_7Cluster5eraseENS_6ObjKeyERNS_12CascadeStateEE3$3EEOT_ENUlPvS3_E_8__invokeESF_S3 + 1303
8 realm-wrappers 0x000000010e51de77 _ZNK5realm16TableClusterTree25for_each_and_every_columnENS_4util11FunctionRefIFNS_15IteratorControlENS_6ColKeyEEEE + 87
9 realm-wrappers 0x000000010e3f751b _ZN5realm7Cluster5eraseENS_6ObjKeyERNS_12CascadeStateE + 203
10 realm-wrappers 0x000000010e40acb0 _ZZN5realm16ClusterNodeInner5eraseENS_6ObjKeyERNS_12CascadeStateEENK3$_3clEPNS_11ClusterNodeERNS0_9ChildInfoE + 48
11 realm-wrappers 0x000000010e406a4d _ZN5realm16ClusterNodeInner5eraseENS_6ObjKeyERNS_12CascadeStateE + 301
12 realm-wrappers 0x000000010e409971 _ZN5realm11ClusterTree5eraseENS_6ObjKeyERNS_12CascadeStateE + 97
13 realm-wrappers 0x000000010e511498 _ZN5realm5Table13remove_objectENS_6ObjKeyE + 280
14 realm-wrappers 0x000000010e13efa5 object_remove + 69
15 ??? 0x000000015e7b8352 0x0 + 5880120146!!! IMPORTANT: Please report this at https://github.com/realm/realm-core/issues/new/choose2022-10-28 13:42:39.195337+0200 CTeleport.Mobile.iOS[47691:4646569] /Users/runner/work/realm-dotnet/realm-dotnet/wrappers/realm-core/src/realm/array_backlink.cpp:108: [realm-core-12.9.0] Assertion failed: int64_t(value >> 1) == key.value [272, 16]
0 realm-wrappers 0x000000010e548ffc _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1 realm-wrappers 0x000000010e548f01 _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 385
2 realm-wrappers 0x000000010e42de77 ZN5realm4util9terminateIJxxEEEvPKcS3_lDpT + 55
3 realm-wrappers 0x000000010e3e1cb1 _ZN5realm13ArrayBacklink6removeEmNS_6ObjKeyE + 577
4 realm-wrappers 0x000000010e472e92 _ZN5realm3Obj19remove_one_backlinkENS_6ColKeyENS_6ObjKeyE + 354
5 realm-wrappers 0x000000010e4733ce _ZNK5realm3Obj15remove_backlinkENS_6ColKeyENS_7ObjLinkERNS_12CascadeStateE + 302
6 realm-wrappers 0x000000010e41f363 _ZNK5realm10Dictionary16remove_backlinksERNS_12CascadeStateE + 243
7 realm-wrappers 0x000000010e3fe947 _ZZN5realm4util11FunctionRefIFNS_15IteratorControlENS_6ColKeyEEEC1IRZNS_7Cluster5eraseENS_6ObjKeyERNS_12CascadeStateEE3$3EEOT_ENUlPvS3_E_8__invokeESF_S3 + 1303
8 realm-wrappers 0x000000010e51de77 _ZNK5realm16TableClusterTree25for_each_and_every_columnENS_4util11FunctionRefIFNS_15IteratorControlENS_6ColKeyEEEE + 87
9 realm-wrappers 0x000000010e3f751b _ZN5realm7Cluster5eraseENS_6ObjKeyERNS_12CascadeStateE + 203
10 realm-wrappers 0x000000010e40acb0 _ZZN5realm16ClusterNodeInner5eraseENS_6ObjKeyERNS_12CascadeStateEENK3$_3clEPNS_11ClusterNodeERNS0_9ChildInfoE + 48
11 realm-wrappers 0x000000010e406a4d _ZN5realm16ClusterNodeInner5eraseENS_6ObjKeyERNS_12CascadeStateE + 301
12 realm-wrappers 0x000000010e409971 _ZN5realm11ClusterTree5eraseENS_6ObjKeyERNS_12CascadeStateE + 97
13 realm-wrappers 0x000000010e511498 _ZN5realm5Table13remove_objectENS_6ObjKeyE + 280
14 realm-wrappers 0x000000010e13efa5 object_remove + 69
15 ??? 0x000000015e7b8352 0x0 + 5880120146!!! IMPORTANT: Please report this at https://github.com/realm/realm-core/issues/new/choose

Steps & Code to Reproduce

public async Task RemoveAsync(List items) where T : RealmObject
{
await _semaphoreSlim.WaitAsync();
await RealmInstance.WriteAsync(() => items.ForEach(s => RealmInstance.Remove(s)));
_semaphoreSlim.Release();
}

@nicola-cab
Copy link
Member

nicola-cab commented Oct 28, 2022

Hello, thanks for reporting this. It seems like the object that was deleted was linked to another object, while we were deleting this relationship we ended up with a value different from what we expected.
Assertion failed: int64_t(value >> 1) == key.value [272, 16]
I need some more digging in order to understand better the how to reproduce this issue.
Just few questions?

  1. What OS are you using?
  2. Is the database OK, can you open the database with Realm Studio and inspect your data?

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Oct 28, 2022
@sledderGIT
Copy link
Author

sledderGIT commented Oct 31, 2022

it's iOS 16.02 I'm debuggin on my mac on iOS simulator.
I don't use the Realm Studio but I assume that the db should be fine cause I read this object from the same db right before deleting it. I do something like
var model = RealmInstance.Find(id)
if(model.IsExpired)
await RealmInstance.WriteAsync(() => RealmInstance.Remove(model));
What does it mean linked to another object?

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Oct 31, 2022
@sync-by-unito sync-by-unito bot removed the Needs-Attention Reporter has responded. Review comment. label Nov 1, 2022
@sledderGIT
Copy link
Author

sledderGIT commented Nov 3, 2022

Ok I think I've figured out how it's happening. I'm capturing the collection of items in one async method and trying to remove some of the same items from another async method. If I do a simple remove operation without any async methods performing the same time the item is removed without any problem.

@nicola-cab
Copy link
Member

Obviously, there is something in the async flow that is causing this. However, it seems to be triggered by the fact that you are trying to remove the same object from the same collection in 2different threads. I'll double-check if this is reproducible in core.
Thanks.

@nicola-cab
Copy link
Member

This is a duplicate of #5299... which is due to database corruptions. For which we have a fix cooking at #5993

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

Successfully merging a pull request may close this issue.

2 participants