signalapp / Signal-Android

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

Signal crashing after transfer/restore #13740

Open mheck-lm opened 1 month ago

mheck-lm commented 1 month ago

Guidelines

Bug description

After Transferring or Restoring from a backup the app asks for confirmation of the phone number but then crashes after confirming the PIN. Any attempts of opening the app after that crash lead to another crash. adb logcat outputs:

10-21 10:57:20.061  7440 13079 E AndroidRuntime: Process: org.thoughtcrime.securesms, PID: 7440
10-21 10:57:20.061  7440 13079 E AndroidRuntime: org.thoughtcrime.securesms.database.RecipientTable$MissingRecipientException: Failed to find recipient with ID: RecipientId::3245
10-21 10:57:20.061  7440 13079 E AndroidRuntime:        at org.thoughtcrime.securesms.database.RecipientTable.findRemappedIdRecord(RecipientTable.kt:759)
10-21 10:57:20.061  7440 13079 E AndroidRuntime:        at org.thoughtcrime.securesms.database.RecipientTable.getRecord(RecipientTable.kt:747)
10-21 10:57:20.061  7440 13079 E AndroidRuntime:        at org.thoughtcrime.securesms.recipients.LiveRecipient.fetchAndCacheRecipientFromDisk(LiveRecipient.java:192)
10-21 10:57:20.061  7440 13079 E AndroidRuntime:        at org.thoughtcrime.securesms.recipients.LiveRecipient.resolve(LiveRecipient.java:152)
10-21 10:57:20.061  7440 13079 E AndroidRuntime:        at org.thoughtcrime.securesms.recipients.Recipient$Companion.resolved(Recipient.kt:837)
10-21 10:57:20.061  7440 13079 E AndroidRuntime:        at org.thoughtcrime.securesms.recipients.Recipient$Companion.resolvedList(Recipient.kt:843)
10-21 10:57:20.061  7440 13079 E AndroidRuntime:        at org.thoughtcrime.securesms.recipients.Recipient.resolvedList(Recipient.kt:0)
10-21 10:57:20.061  7440 13079 E AndroidRuntime:        at org.thoughtcrime.securesms.conversationlist.ConversationListDataSource.load(ConversationListDataSource.java:103)

Screenshots

No response

Device

Samsung Galaxy A55

Android version

14

Signal version

7.19.2

Link to debug log

No response

mheck-lm commented 1 month ago

We found the following entries in the Debug log:

10-24 14:34:08.086 14901  9853 W RecipientTable: Missing recipient for RecipientId::3245, but found it in the remapped records as RecipientId::3256
10-24 14:34:08.086 14901  9851 W RecipientTable: Missing recipient for RecipientId::3245, but found it in the remapped records as RecipientId::3256

With further search we found two chats that contained "strange" contents:

  1. There was a "Message request" message displayed beneath a name, but within the chat was none visible only a few "safety number changed" messages
  2. Nothing was displayed beneath a name but in the chat was something around "updating the contact because it has changed"

⇒ After deleting both these chats we were able to migrate to the new phone successfully!

anneaux commented 2 weeks ago

I experience the very same, on a Samsung Galaxy S21 5G, Android 13. As I don't have my old phone anymore and am only left with the backup file, is it still possible to delete the chats somehow (assuming this might solve the problem)?!

codeceptsDE commented 2 weeks ago

Same issue. I, too, have the "Failed to find recipient with ID: RecipientId::124" exception (different ID of course, but not "null" as in #10868, for example). The comment by @mheck-lm led me to my solution: I also had two unusual chats; by deleting them on the old device, I could create a new backup and restore it on the new device successfully.

  1. A "message request" from some spam/scam number. Unless Signal has some block list, I think this is not the cause, but I cannot say definitively that this had no effect, or that transferring backups with open message requests works at all.
  2. A "message request" from someone, that showed in chat also as "merged" with another number. I suspect this is the culprit, as it sounds quite similar to message 2 from @mheck-lm.

The exception is defined here, and thrown here: https://github.com/signalapp/Signal-Android/blob/aad2624bd551c122a8938c12fe2d2240c950b8f4/app/src/main/java/org/thoughtcrime/securesms/database/RecipientTable.kt#L752-L761

It sounds quite plausible to me that this combination of "message request" + "remapped contact" might be the edge case that triggers this exception.

At the very least, this exception (and others like it!) should be caught and handled more gracefully, as it completely breaks the restore/transfer flow, even rendering the app unusable until purging data or re-installing. Considering findRemappedIdRecord may not be the only unsafe function call, it may be better to have a single chat display some error and be unrecoverable, than the entire history or the entire app.

codeceptsDE commented 2 weeks ago

I experience the very same, on a Samsung Galaxy S21 5G, Android 13. As I don't have my old phone anymore and am only left with the backup file, is it still possible to delete the chats somehow (assuming this might solve the problem)?!

Not trivially. The app will not allow you to, as it keeps crashing before you get there. Unless a fix for this bug is released. If you don't have the old phone to make the changes there, you would need to fix the backup file externally, by decrypting and modifying it manually. That should technically be possible, since you can find (unofficial) decryption tools e.g. on GitHub, and you supposedly have access to your 30-digit backup passphrase. But you would essentially need to reverse-engineer the steps the Signal app executes when deleting a user by yourself.

Edit: This tool may be worth a shot. It claims to be able to modify/crop backup files. I have no affiliation with/no experience with this tool, though.

mjszczep commented 5 days ago

I'm seeing this issue when I try to restore a backup as well:

11-24 02:46:11.439 26318 26369 E AndroidRuntime: org.thoughtcrime.securesms.database.RecipientTable$MissingRecipientException: Failed to find recipient with ID: RecipientId::81
11-24 02:46:11.439 26318 26369 E AndroidRuntime:    at org.thoughtcrime.securesms.database.RecipientTable.findRemappedIdRecord(RecipientTable.kt:763)
11-24 02:46:11.439 26318 26369 E AndroidRuntime:    at org.thoughtcrime.securesms.database.RecipientTable.getRecord(RecipientTable.kt:751)
11-24 02:46:11.439 26318 26369 E AndroidRuntime:    at org.thoughtcrime.securesms.recipients.LiveRecipient.fetchAndCacheRecipientFromDisk(LiveRecipient.java:192)
11-24 02:46:11.439 26318 26369 E AndroidRuntime:    at org.thoughtcrime.securesms.recipients.LiveRecipient.resolve(LiveRecipient.java:152)
11-24 02:46:11.439 26318 26369 E AndroidRuntime:    at org.thoughtcrime.securesms.recipients.LiveRecipientCache$$ExternalSyntheticLambda4.run(R8$$SyntheticClass:0)
11-24 02:46:11.439 26318 26369 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
11-24 02:46:11.439 26318 26369 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
11-24 02:46:11.439 26318 26369 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:1012)
11-24 02:46:11.439 26318 26369 E AndroidRuntime:    at org.signal.core.util.concurrent.SignalExecutors$NumberedThreadFactory$1.run(SignalExecutors.java:109)

I poked around at signalbackup-tools a bit but don't quite understand if there's an straightforward way to identify and crop out the offending chats. Hopefully this bug can get fixed soon!