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

Invalid top array size (ref: 2224064, array size: 655360) file size: 0 #8035

Open
BlueCobold opened this issue Sep 24, 2024 · 8 comments
Open

Comments

@BlueCobold
Copy link

SDK and version

SDK : RealmKotlin
Version: 2.2.0 (Core 14.12.0)

Observations

  • How frequent do the crash occur?
    Rarely
  • Does it happen in production or during dev/test?
    Production
  • Can the crash be reproduced by you?
    No
  • Can you provide instructions for how we can reproduce it?
    No

Crash log / stacktrace

Failed to memory buffer:Invalid top array size (ref: 2224064, array size: 655360) file size: 0, read lock size: none, read lock version: none:
java.lang.IllegalStateException: [RLM_ERR_INVALID_DATABASE]: Failed to open Realm file at path "....": Failed to memory buffer:Invalid top array size (ref: 2224064, array size: 655360) file size: 0, read lock size: none, read lock version: none
at io.realm.kotlin.internal.interop.CoreErrorConverter.asThrowable(SourceFile:96)
at io.realm.kotlin.internal.interop.realmcJNI.realm_open(Native Method)
at io.realm.kotlin.internal.interop.realmc.realm_open(SourceFile:1)
at io.realm.kotlin.internal.interop.RealmInterop.realm_open(SourceFile:41)
at io.realm.kotlin.internal.ConfigurationImpl.openRealm$lambda$0(SourceFile:18)
at io.realm.kotlin.internal.ConfigurationImpl.a(SourceFile:1)
at io.realm.kotlin.internal.b.invoke(SourceFile:1)
at io.realm.kotlin.internal.interop.NativePointerKt.use(SourceFile:11)
at io.realm.kotlin.internal.ConfigurationImpl.openRealm$suspendImpl(SourceFile:20)
at io.realm.kotlin.internal.ConfigurationImpl.openRealm(SourceFile:1)
at io.realm.kotlin.internal.RealmImpl$1.invokeSuspend(SourceFile:138)
at kotlin.coroutines.jvm.internal.a.resumeWith(SourceFile:12)
at kotlinx.coroutines.DispatchedTask.run(SourceFile:129)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(SourceFile:82)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(SourceFile:27)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(SourceFile:77)
at kotlinx.coroutines.BuildersKt.runBlocking(SourceFile:1)
at io.realm.kotlin.internal.platform.CoroutineUtilsSharedJvmKt.runBlocking(SourceFile:11)
at io.realm.kotlin.internal.platform.CoroutineUtilsSharedJvmKt.runBlocking$default(SourceFile:7)
at io.realm.kotlin.internal.RealmImpl.\u003cinit\u003e(SourceFile:15)
at io.realm.kotlin.internal.RealmImpl.\u003cinit\u003e(SourceFile:1)
at io.realm.kotlin.internal.RealmImpl$Companion.create$io_realm_kotlin_library(SourceFile:9)
at io.realm.kotlin.Realm$Companion.open(SourceFile:10)

Steps & Code to Reproduce

I sadly do not have the file in question. However, a broken topRef means there are still bugs which make Realm not ACID and a reported file size of 0 means the error message is incorrect as well, because if it was 0 bytes in size, there would not be a readable topRef at all.

Copy link

sync-by-unito bot commented Sep 24, 2024

➤ PM Bot commented:

Jira ticket: RCORE-2260

@nicola-cab
Copy link
Member

Hello @BlueCobold thanks for reporting this. Without the file however it is almost impossible to understand what happened.

Clearly, the top ref array is not valid:

void Group::validate_top_array(const Array& arr, const SlabAlloc& alloc, std::optional<size_t> read_lock_file_size,

I can only think about something bad happening when a transaction was committed.
Do you have more information on your side that can give us some tips about how to try to reproduce this issue?

@BlueCobold
Copy link
Author

I'm afraid I can not provide more info that this crash report. I understand it's probably super hard to identify. I can say that access to the realm is temporary opened and closed in a single-threaded exclusive way. If it's impossible to find a reason for such an invalid top-ref, I'm sure you can at least correct the wrong error-message which claims the file-size to be 0, which is logically impossible if a top-ref can be read.

@jedelbo
Copy link
Contributor

jedelbo commented Sep 26, 2024

The file size we are referring to here is the logical file size that is stored in the top array. So if the top ref is pointing to some invalid array, that size can perfectly fine be 0.
Unfortunately we have not been able to find the reason why the top ref can be wrong. Can you tell on which platform this is happening? Historically we have only seen these kind of problems on iOS. So the theory is that something weird is going on in the file system - possibly if the platform crashes.

@BlueCobold
Copy link
Author

Ah, I see. So it's a confusing message, because it says "array size: 655360), file size: 0".

It happened on Android.

@nicola-cab
Copy link
Member

nicola-cab commented Sep 26, 2024

@jedelbo I may be wrong (because I don't recall in detail what we did). But as far as I remember, we only added the extra msync call for IOS and left the management of the dirty pages untouched for the other platforms. I repeat, I might be wrong on this.
Probably this is just speculation, though.

@sync-by-unito sync-by-unito bot closed this as completed Sep 27, 2024
Copy link

sync-by-unito bot commented Sep 27, 2024

➤ jedelbo commented:

Without having the file, I can't see how we can move forward on this issue, I I will close it.

@BlueCobold
Copy link
Author

@jedelbo The issue persists. I keep getting reports.

Failed to open Realm file at path "...": Failed to memory buffer:Invalid top array size (ref: 2882016, array size: 16777215) file size: 108086541928145056, read lock size: none, read lock version: none

@jedelbo jedelbo reopened this Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants