signalapp / Signal-Android

A private messenger for Android.
https://signal.org
GNU Affero General Public License v3.0
25.72k stars 6.17k forks source link

Signal crashes on restoring backup #13506

Closed asdfjkl closed 52 minutes ago

asdfjkl commented 8 months ago

Bug description

Signal crashes on restoring a (valid) backup file. In particular when starting restoring from a file backup, messages seems to be processed and imported correctly. However afterwards, Signal crashes repeatedly on startup and cannot be started anymore, i.e. Android reports that the app is crashing repeatedly responding.

I've verified that the backup is intact with 3rd party tools (signal-backup-tools). I've also verified that the passphrase is correct; in particular I was able to extract all messages with signal-backup-tools (https://github.com/bepaald/signalbackup-tools) to text format and verified that all information is present. I've also tried to (re)write the backup using backup-tools in order to check that the backup file is not corrupted.

The database version as reported from signal-backup-tools: 136 Signal-Version: 7.2.4

The backup is from 2022; so I suspect that there is some issues when handling such "old" backups. The backup contains personal information, but I am willing to help w.r.t. debugging this issue in any way I can

Steps to reproduce

Actual result: Signal crashes and can't be started anymore Expected result: Should restore the backup and start as expected

Screenshots

unfortunately I have no screenshot

Device info

Device: Pixel 6a Android version: 14 Signal version: 7.2.4

Link to debug log

signal-log-1712506609190.zip attached to this report

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

asdfjkl commented 5 months ago

any news on this? I think this should not be closed, as there is apparently an issue with old backups, likely affecting other users as well.

itsluminous commented 3 months ago

Hey I am also having this issue. Device : Samsung Galaxy S21 FE. Backup Date : June 2022

I decided to give Signal one more try after a couple of years, and now restore won't work. Immediately after restore the app crashes. Tried restoring different backups I had, same result.

cody-signal commented 3 months ago

Are y'all able to capture logs with adb logcat or some other tool to see what the crash is? The OP log link doesn't have any crash data in it.

itsluminous commented 3 months ago

@cody-signal I have attached my logs here : crash_logs.zip To me it looks like a particular DB migration is failing:

08-17 03:03:08.556 13816 18959 I SignalDatabaseMigration: Successfully completed migration for version 228 in 1 ms
08-17 03:03:08.556 13816 18959 I SignalDatabaseMigration: Running migration for version 229: V229_MarkMissedCallEventsNotified. Foreign keys: false
08-17 03:03:08.556 13816 18959 E SQLiteLog: (267) statement aborts at 10: [UPDATE message
08-17 03:03:08.556 13816 18959 E SQLiteLog: SET notified = 1
08-17 03:03:08.556 13816 18959 E SQLiteLog: WHERE (type = 3) OR (type = 8)] database disk image is malformed
08-17 03:03:08.627 13816 18959 E SqlCipherErrorHandler: Database 'signal.db' corrupted!
08-17 03:03:08.627 13816 18959 E SqlCipherErrorHandler: [sqlite] FullCode: 267 | ErrorCode: 11 | ExtendedErrorCode: 1 | Message: database disk image is malformed | ExtraMessage: null
08-17 03:03:08.627 13816 18959 E SqlCipherErrorHandler: Diagnostic results:
08-17 03:03:08.627 13816 18959 E SqlCipherErrorHandler:   ===== PRAGMA integrity_check (same-connection) =====
08-17 03:03:08.627 13816 18959 E SqlCipherErrorHandler: ok
08-17 03:03:08.627 13816 18959 E SqlCipherErrorHandler: 
08-17 03:03:08.627 13816 18959 E SqlCipherErrorHandler: ===== PRAGMA cipher_integrity_check (same-connection) =====
08-17 03:03:08.627 13816 18959 E SqlCipherErrorHandler: 
08-17 03:03:08.627 13816 18959 W SearchTable: [fullyResetTables] Dropping tables and triggers...
08-17 03:03:08.629 13816 18959 W SearchTable: [fullyResetTables] Recreating table...
08-17 03:03:08.630 13816 18959 W SearchTable: [fullyResetTables] Recreating triggers...
08-17 03:03:08.632 13816 18959 I Job     : [JOB::769064ee-dc56-4e35-9288-a26a4808ea60][RebuildMessageSearchIndexJob] onSubmit() (Time Since Submission: 1 ms, Lifespan: Immortal, Run Attempt: 1/3, Queue: RebuildMessageSearchIndex)
08-17 03:03:08.632 13816 18959 W SearchTable: [fullyResetTables] Done. Index will be rebuilt asynchronously)
08-17 03:03:08.633 13816 18959 I JobManager: onConstraintMet(DataRestoreConstraint)
08-17 03:03:08.633 13816 14074 I JobRunner: [JOB::769064ee-dc56-4e35-9288-a26a4808ea60][RebuildMessageSearchIndexJob][3] Running job. (Time Since Submission: 2 ms, Lifespan: Immortal, Run Attempt: 1/3, Queue: RebuildMessageSearchIndex)
08-17 03:03:08.634 13816 14042 I JobSchedulerScheduler: JobScheduler enqueue of  (0)
08-17 03:03:08.638 13816 14074 I SearchTable: Re-indexing. Operating on ID's 1-4686 in steps of 10000.
08-17 03:03:08.638 13816 14074 I SearchTable: Reindexing ID's [1, 10001)
08-17 03:03:08.640  1526  3302 D FreecessController: org.thoughtcrime.securesms(10778) is important[18]
08-17 03:03:08.641 13816 13816 E SignalUncaughtException: java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction.
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at net.zetetic.database.sqlcipher.SQLiteSession.throwIfNoTransaction(SQLiteSession.java:950)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at net.zetetic.database.sqlcipher.SQLiteSession.endTransaction(SQLiteSession.java:402)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at net.zetetic.database.sqlcipher.SQLiteDatabase.endTransaction(SQLiteDatabase.java:572)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at org.signal.core.util.SQLiteDatabaseExtensionsKt.withinTransaction(SQLiteDatabaseExtensions.kt:23)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at org.thoughtcrime.securesms.database.helpers.SignalDatabaseMigrations.migrate(SignalDatabaseMigrations.kt:214)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at org.thoughtcrime.securesms.database.SignalDatabase.onUpgrade(SignalDatabase.kt:176)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at org.thoughtcrime.securesms.database.SignalDatabase$Companion.runPostBackupRestoreTasks(SignalDatabase.kt:289)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at org.thoughtcrime.securesms.restore.RestoreRepository$restoreBackupAsynchronously$2.invokeSuspend(RestoreRepository.kt:64)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
08-17 03:03:08.641 13816 13816 E SignalUncaughtException:   Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@f254568, Dispatchers.Main.immediate]
08-17 03:03:08.646 13816 13816 I JobManager: Successfully flushed.
itsluminous commented 3 months ago

something that may help in debugging -

cody-signal commented 3 months ago

Thanks for the additional information and the troubleshooting steps, we'll do our best to figure this out.

arc-des commented 3 weeks ago

Hi! I also have this issue when attempting to restore (valid/functioning) backups from 2021 and 2020 (Backup db version 105 and 44 respectively).

The restore seems to go fine, then crashes at the last block.

Restoring into an older version of Signal using an old APK appears to work fine, however I can't register/verify my number as it gives an "Unable to connect to service" toast, preventing me from getting in and updating it post-restore (attempts to do so cause crashes or it puts me back to the pre-restore welcome screen)

Let me know if I can help provide additional info. I'd really like to restore these backups - my newer ones are all corrupted for some reason, despite semi-regular backing up over the last year or so. I wish Signal had a way to check backup integrity without wiping and restoring the app (or using another phone I suppose) -would have saved me some stress!

Many thanks :)

Leunammih commented 4 days ago

Hi! I found a solution for restoring a large, old backup file from signal on my Android device.

Since I recently started using the MacBook with M1 Chip and ARM64 architecture, I couldn't even use signal backup tool to verify which db Version my backup was using.

What worked to restore the backup, however, was installing an old version of the android app. Before it always crashed, after loading the local backup file which was 4.2GB large and entering the Passphrase. To solve it, I did the following:

I checked the date that my Signal Backup was created (in my case September 2024) → found the corresponding Signal App from the date of the backup in https://www.apkmirror.com/uploads/?appcategory=signal-private-messenger that was listed for that time (again, in my case September 2024, which was Signal Private Messenger 7.16.4). Since I didn't have my old Android Phone after the switch to iPhone, I installed MuMuPlayer Pro (an Android emulator for MacBook, others should also work, I think), then installed the old Version of the Signal App, restored with local backup and tadaaa... it worked. I now have access to my old backup again.

What I want to check is, if updating the Android Signal app and then making a new backup in that version will make it restorable in newer versions of Signal too...

Hope that helps.