Signal-Android icon indicating copy to clipboard operation
Signal-Android copied to clipboard

FullBackupImporter.trimEntriesForExpiredMessages() crashes.

Open JKAbrams opened this issue 8 years ago • 5 comments

I was on CopperheadOS Noise (copy of Signal) due to the forced upgrade Noise stopped working and I had no option but to move to Signal. It was not possible to install Signal while Noise was still installed, needless to say Noise created a broken backup so I'm stuck with all my (important) messages contained in a broken backup.

While restoring the messages Signal crashes:

debug.log

I understand the SQL statements are broken (https://github.com/signalapp/Signal-Android/commit/7f7aab044cc6ca2989c3f949c7dbeff13ec39dd6), so guess I need to find a way to fix them. As far as I understand it I have now two options:

  • [proper fix] Fix the parser so that it does not choke on broken backups, (even a partial restore where broken messages are discarded is way better than no messages at all).
  • [workaround] Decrypt my backup and fix the SQL manually, I looked into this but it seems Signal uses it's own encryption format for the file so then I would have to build a tool that can decrypt and encrypt the file so at this point it seems easier to try to use the application in order to work on the file.

My backup is 900mb, and needless to say I cannot post it. It always fails on the same message and it looks like most messages work.

The log indicates that backup.FullBackupImporter.trimEntriesForExpiredMessages causes the problem, so I'll start looking at this function to try to figure out how it can be fixed or at least improved to work around the problem.

Any help appreciated for how to fix it, I don't think I'm the only one with this problem as Noise expired today.

JKAbrams avatar Jul 20 '18 04:07 JKAbrams

[workaround] Decrypt my backup

There are (at least) two command line tools that are capable of decrypting Signal backups:

  • https://github.com/pajowu/signal-backup-decode
  • https://github.com/xeals/signal-back

Maybe you can utilize them somehow - I already used the first one at it worked without any problems.

That said, I think the Signal team will probably close this issue as this seems to be no bug of Signal itself (but rather Noise) and the GitHub issue tracker is only supposed to be used for bugs in the software (https://github.com/signalapp/Signal-Android/blob/master/CONTRIBUTING.md#issues), no discussions or feature requests. The best place for discussion regarding backups would probably be the community forum: https://community.signalusers.org/

minnmann avatar Jul 20 '18 05:07 minnmann

Thanks for the your suggestion, I'll try my luck with the tools.

Noise was previously a separate project but was changed into nothing more than a copy of Signal, so essentially backups created by an old version of Signal cannot be opened with a new version of Signal and so Signal could be improved if it could do more than crash on old backup versions.

JKAbrams avatar Jul 20 '18 06:07 JKAbrams

I am also migrating from an encrypted Noise backup with the same stack trace. I don't think the problem is Noise specifically but rather importing backups made by older versions of Signal, which include group receipts for expired messages.

I tested several versions of Signal using @johanw666 forked releases (in airplane mode), but you could also compile Signal directly from source instead. 4.21.4 succeeds in importing the backup but 4.21.6 and newer do not. The git history would suggest that the culprit is 71a34da which is also where the trimEntriesForExpiredMessages method was introduced.

So as a workaround I installed Signal 4.21.4, imported the backup, and then upgraded to the latest version. Or use the fork, upgrade the fork, and then export a proper backup which excludes expired messages and can be imported into latest Signal.

daradib avatar Jul 20 '18 08:07 daradib

I built 4.12.4 from source and I can confirm that restoring the Noise backup works in this version.

JKAbrams avatar Jul 20 '18 15:07 JKAbrams

@daradib Thanks for digging into this. It appears that trimEntriesForExpiredMessages() was written in such a way where it isn't compatible with older database versions. I think that's the real actionable bug here from our perspective.

greyson-signal avatar Jul 20 '18 16:07 greyson-signal