TeamWin / Team-Win-Recovery-Project

Core recovery files for the Team Win Recovery Project (T.W.R.P) - this is not up to date, please see https://github.com/TeamWin/android_bootable_recovery/
http://twrp.me
1.97k stars 740 forks source link

OOM kill results in failure of createTarFork() when running adb backup --twrp #1609

Open happysmash27 opened 3 years ago

happysmash27 commented 3 years ago

Device codename: bacon TWRP version: 3.5.2_9-0

WHAT STEPS WILL REPRODUCE THE PROBLEM?

WHAT IS THE EXPECTED RESULT?

The contents of my Boot, System, and Data partitions, are all backed up to my computer, bypassing my phone's limited internal storage.

WHAT HAPPENS INSTEAD?

ADDITIONAL INFORMATION

/tmp/recovery.log: https://happysmash27.me/Upload/Logs/TWRP/2021-05-26--11-49-04_lineage_bacon-userdebug_9_PQ3A190801002_858/recovery.log dmesg: https://happysmash27.me/Upload/Logs/TWRP/dmesg_2021-05-26_1.log

Additionally, several other logs for the same error are available in my comments for #1376.

The program also seems to hang after:

Backup Failed. Cleaning Backup Folder. 
Backup Failed

Disk usage does not change at all on either my phone or the computer it is being backed up to.

bigbiff commented 3 years ago

Does this happen on backups using the TWRP menu interface?

happysmash27 commented 3 years ago

I can't back up using the TWRP menu interface (to my knowledge), as I would quickly run out of space in my internal storage, and the function to mount an external disk over USB OTG does not work. I am backing up over 20GB worth of files and only have a /sdcard with 2.6GB free.

wombatch commented 3 years ago

I have exactly the same problem, sadly slightly older software TWRP 3.2.3 on a Sony Z5C. As for you it all used to work fine on my phone, I have to admit I didn't take a back up for a while and now I can't. My perception is (maybe didn't dig as far as you) is that something is stopping TWRP from creating the split archive, each archive file ( data.ext4.winXXX) as far as I can see should get to about 1.5GB before creating a new one, on my system a single data archive gets to about 2.2GB and then the processes all get cancelled. It's very frustrating, I get the same effect from the GUI and by running from ADB

happysmash27 commented 3 years ago

Since it seemed to be an OOM error and there was no swap file:

~ # free -m
             total         used         free       shared      buffers
Mem:       2949976      1772168      1177808            0       383332
-/+ buffers:            1388836      1561140
Swap:            0            0            0

I decided to create my own swap file:

~ # dd if=/dev/zero of=/sdcard/swapfile bs=4M count=256
256+0 records in
256+0 records out
1073741824 bytes (1.0GB) copied, 52.261909 seconds, 19.6MB/s
~ # mkswap /sdcard/swapfile
Setting up swapspace version 1, size = 1073737728 bytes

However, apparently the swapon command is broken =(-_-)= :

~ # swapon /sdcard/swapfile
swapon: /sdcard/swapfile: Function not implemented

Or maybe, hopefully, I just did something wrong and this can be fixed.

happysmash27 commented 3 years ago

I think I'm going to need to recompile the kernel for this: https://www.acmesystems.it/ts_swapon_failed

Um... anyone know some good documentation on that for whatever kernel TWRP uses?

At this rate, though, I'm probably going to get an error when trying to do that too...

axeluhl commented 6 months ago

Same problem here. Was on TWRP 3.1 (gohan) on an old bq Aquaris X5 Plus, and TWRP used to work like a charm, but then stopped with the nasty signal: 9 issue. I've upgraded to 3.7.0_9-0 (gohan), but this doesn't change anything. Like @wombatch noted, the last archive part grows to approximately 2.2GB before the signal: 9 stops the process.

I'm looking at the contents of the last data.ext4.win005 archive. It has 463,257 files, many of them seem very small. It ends with files from an RSS reader app I'm using:

data/data/com.madsvyat.simplerssreader/files/.Fabric/com.crashlytics.sdk.android.crashlytics-core/{UUID}eginSession.cls

and so on. Checking this .Fabric/ folder shows: du -sh .Fabric/ 1.8G .Fabric/

I'm removing the entire .Fabric folder now. (Good news: after removing, the RSS feed reader still seems to work :-)). Now I'll try the back up again. And what can I say... it works again!

So, my recommendation is to look at the last segment of your data.ext.win* files, e.g., with a tar tvpf data.ext.win005 | tail and see what TWRP was trying to write when it crashed. For me, this gave a hint as to where to look for the issue.

Of course, the underlying issue seems to be that some aspect of TWRP doesn't scale properly. Even with very large numbers of files in certain folders, splitting the backup into TAR segments properly should of course still work.