realm / realm-kotlin

Kotlin Multiplatform and Android SDK for the Realm Mobile Database: Build Better Apps Faster.
Apache License 2.0
968 stars 61 forks source link

Segfault on load DB #1487

Open JorisBodin opened 1 year ago

JorisBodin commented 1 year ago

How frequently does the bug occur?

Sometimes

Description

Our app crashed for some users (including me) at launch, when loading the database. And this only happens once per user. We suspect it's due to a migration ... This migration: https://github.com/Infomaniak/android-kMail/blob/1.0.9/app/src/main/java/com/infomaniak/mail/data/cache/RealmDatabase.kt#L175

Stacktrace & log output

OS Version: Android 13 (TQ3A.230805.001)
Report Version: 104

Exception Type: Unknown (SIGSEGV)

Application Specific Information:
Segfault

Thread 0 Crashed:
0   libart.so                       0x6d179e5f6c        <unknown> + 468547690348
1   split_config.arm64_v8a.apk      0x6c91704f48        register_results_notification_cb
2   split_config.arm64_v8a.apk      0x6c91702744        Java_io_realm_kotlin_internal_interop_realmcJNI_register_1results_1notification_1cb
3   base.odex                       0x6c9a7a4744        <unknown> + 466448172868

https://sentry-mobile.infomaniak.com/share/issue/1dd3e2bd23154ad0982af11835ad33d3/

Can you reproduce the bug?

No

Reproduction Steps

No response

Version

1.10.2

What Atlas App Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Android 12 and 13

Build environment

https://github.com/Infomaniak/android-kMail/blob/1.0.9/app/build.gradle https://github.com/Infomaniak/android-kMail/blob/1.0.9/gradle/libs.versions.toml#L17

JorisBodin commented 1 year ago

This always happens with "1.11.1".

And given the breadcrump, I don't think it's migration.

It's getting to be a lot 😬

image

https://sentry-mobile.infomaniak.com/share/issue/1dd3e2bd23154ad0982af11835ad33d3/ https://sentry-mobile.infomaniak.com/share/issue/293c388ca27f4c82bf24efdc41aebf16/

JorisBodin commented 1 year ago

All events affect only android 12 and 13 devices

I checked, we already had 1.10.2 realm on our application in 1.0.8.

But what's changed on our side is that we've gone from compileSdk 33 to 34 https://github.com/Infomaniak/android-kMail/compare/1.0.8...1.0.9

Is Android 14 the problem?

cmelchior commented 1 year ago

Hi @JorisBodin

I don't think Android 14 is the problem. My guess is you are trying to register a change listener to a type deleted by the migration, but I'm not sure how that is possible.

Following your migration logic it looks like you ended up calling newRealm.deleteAll() which should be fine and at least I could not reproduce the error using the same method.

I'm still investigating it.

JorisBodin commented 1 year ago

Hello @cmelchior,

The problem occurred between 1.0.8 and 1.0.9 The newRealm.deleteAll() was already present before 1.0.8, so that's not the problem.

Thank you

rorbech commented 11 months ago

The stacktrace looks like it could be related to #1598. The callback class reference did not create a global reference so the class could potentially be unloaded behind the scene of the static initalized jclass.

I can't explain how this would be related to migration though, but maybe the issue is otherwise related to two simultaneous instances of the app during an upgrade.

JorisBodin commented 11 months ago

What version will be available?

rorbech commented 11 months ago

@JorisBodin The above fix will be in 1.14.0. It is already available in 1.14.0-SNAPSHOT (using snapshots) if you want to see if it changes anything already.

JorisBodin commented 11 months ago

Not reproducing the bug, we'll see if the error disappears from sentry after 1.14.0 update 🤞

rorbech commented 7 months ago

@JorisBodin This popped up from another user on 1.14.1. Are you still seeing this and have you been able to gather more insights on exactly when it is happening?

github-actions[bot] commented 6 months ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

JorisBodin commented 6 months ago

@tevincent explained here https://github.com/realm/realm-kotlin/issues/1726#issuecomment-2084500711 I thought that was enough

Is it possible to reopen the PR?

Thanks

JorisBodin commented 5 months ago

Need more info?