realm-core icon indicating copy to clipboard operation
realm-core copied to clipboard

Crash with "Assertion failed: index < m_local_max_entry"

Open FSI-Takahiro-Ooki opened this issue 2 years ago • 3 comments

Hi, Our APP has Assertion happening in Realm-core.

Description

We think that this issue is caused by our APP misusing Realm API usage. However, we don't know the reason for this assertion, so I can't fix it correctly.

Please let me know this assert reason, and we hope your support.

SDK and version

SDK : Swift realm-cocoa:10.25.2 realm-core:11.15.0

Observations

  • Can the crash be reproduced by you? YES. Reproduce after 2 hours or more operating.

Crash log / stacktrace

/SourcePackages/checkouts/realm-core/src/realm/db.cpp:2406: [realm-core-11.15.0] Assertion failed: index < m_local_max_entry
0   MyApplication          0x00000001058a767c _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1   MyApplication          0x00000001058a7534 _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 228
2   MyApplication          0x000000010512049c _ZN5realm2DB19grow_reader_mappingEj + 160
3   MyApplication          0x0000000105120084 _ZN5realm2DB14grab_read_lockERNS0_12ReadLockInfoENS_9VersionIDE + 196
4   MyApplication          0x00000001051199b4 _ZN5realm2DB10start_readENS_9VersionIDE + 408
5   MyApplication          0x00000001052b9a4c _ZN5realm5_impl16RealmCoordinator10begin_readENS_9VersionIDEb + 144
6   MyApplication          0x00000001053f6d78 _ZN5realm5Realm10begin_readENS_9VersionIDE + 160
7   MyApplication          0x00000001053f6c40 _ZN5realm5Realm11transactionEv + 112
8   MyApplication          0x00000001053f6bc4 _ZN5realm5Realm10read_groupEv + 24
9   MyApplication          0x00000001053f85e0 _ZN5realm5Realm10do_refreshEv + 608
10  MyApplication          0x00000001053fdd38 _ZN5realm5Realm7refreshEv + 36
11  MyApplication          0x0000000104fe9fac -[RLMRealm refresh] + 92
12  MyApplication          0x0000000105a1b4cc $s10RealmSwift0A0V7refreshSbyF + 48

FSI-Takahiro-Ooki avatar Jul 15 '22 11:07 FSI-Takahiro-Ooki

Hello, Thanks for reporting this. I think this is a known issue of Realm.

In which we keep growing the database virtual space, especially the fact that it is reproducible if you leave something running for hours, is most probably indicating that this is the issue your app is facing.

Are you using Frozen objects? If you are not, the only way you can mitigate this issue is to release rapidly the changes you are making to your object by committing the transaction, in order to avoid to keep "alive" (in the file and in memory) an object version that will be overwritten by another transaction.

We are working to release a new major realm release for fixing this behaviour.

nicola-cab avatar Jul 15 '22 15:07 nicola-cab

It is something else, it's not about the file growing. The assert indicates an attempt to refer to a part of the lock-file (not the database/realm file) which does not exist. @FSI-Takahiro-Ooki are you doing anything to the lock-file? I assume you are not, and in that case it looks like a bug in our version management. Are you running in a multi-process scenario by any change?

Anyhow, the relevant code paths are in the process of being rewritten, so it may be fixed by a release in the near future.

@FSI-Takahiro-Ooki you write that you suspect you are "misusing the realm API" ... could you share a bit more details on this suspicion?

finnschiermer avatar Jul 18 '22 08:07 finnschiermer

Thanks for your quick response.

@FSI-Takahiro-Ooki are you doing anything to the lock-file? I assume you are not, and in that case it looks like a bug in our version management. Are you running in a multi-process scenario by any change?

Is lock-file ".realm.xxx" files? we don't touch there.

My application is using Realm with multi thread. As a test, I modified to use Realm to dispatch specific thread. Looks like this assert did not occur. (i am testing more.)

Is this action correct?

@FSI-Takahiro-Ooki you write that you suspect you are "misusing the realm API" ... could you share a bit more details on this suspicion?

It does not have any meaning. I can not the any information for this assert on the web sites. So, i think that this assert is occurred only my App.

FSI-Takahiro-Ooki avatar Jul 18 '22 10:07 FSI-Takahiro-Ooki

➤ Nicola Cabiddu commented:

Closing this, because I cannot reproduce the issue a no more details were shared. Moreover, most probably this issue will be fixed once this PR: https://github.com/realm/realm-core/pull/5440 gets merged.

sync-by-unito[bot] avatar Aug 24 '22 15:08 sync-by-unito[bot]