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

Segfault on load DB

Open JorisBodin opened this issue 1 year ago • 12 comments

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 avatar Aug 23 '23 08:08 JorisBodin

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 avatar Sep 27 '23 16:09 JorisBodin

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?

JorisBodin avatar Sep 27 '23 16:09 JorisBodin

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.

cmelchior avatar Oct 03 '23 09:10 cmelchior

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

JorisBodin avatar Oct 03 '23 11:10 JorisBodin

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.

rorbech avatar Dec 11 '23 13:12 rorbech

What version will be available?

JorisBodin avatar Dec 11 '23 14:12 JorisBodin

@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.

rorbech avatar Dec 12 '23 12:12 rorbech

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

JorisBodin avatar Dec 12 '23 12:12 JorisBodin

@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?

rorbech avatar Apr 19 '24 09:04 rorbech

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.

github-actions[bot] avatar May 06 '24 00:05 github-actions[bot]

@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 avatar May 06 '24 07:05 JorisBodin

Need more info?

JorisBodin avatar Jun 24 '24 09:06 JorisBodin