topjohnwu / Magisk

The Magic Mask for Android
GNU General Public License v3.0
49.16k stars 12.64k forks source link

Direct Install failed: `Unable to patch ramdisk` #8013

Closed Unknown78 closed 5 months ago

Unknown78 commented 7 months ago

Device: Samsung Galaxy Note 4 SM-N910H Android version: 7.1.1 Nougat (API 25) Magisk version name: debug Magisk version code: 27002 (81658d45) [Download]

I've already direct installed with 27001 (3d91a561). It was fine to direct install in the previous version, but now it is not.

I was able to update the App to 27002 (81658d45), but not when direct install the Magisk.

System:

Boot:


magisk_install_log_2024-04-28T11.16.17.log

- Target image: /dev/block/mmcblk0p9
- Device platform: armeabi-v7a
- Installing: 81658d45 (27002)
- Unpacking boot image
Parsing boot image: [/dev/block/mmcblk0p9]
HEADER_VER      [0]
KERNEL_SZ       [4820240]
RAMDISK_SZ      [3236857]
SECOND_SZ       [0]
EXTRA_SZ        [1099776]
OS_VERSION      [7.1.1]
OS_PATCH_LEVEL  [2019-01]
PAGESIZE        [2048]
NAME            [SYSMAGIC000KU]
CMDLINE         [buildvariant=userdebug]
CHECKSUM        [fc1241c0eee33313782b678b259221c2cf4d764b000000000000000000000000]
! Could not find zImage gzip piggy, keeping raw kernel
KERNEL_FMT      [zimage]
RAMDISK_FMT     [gzip]
EXTRA_FMT       [raw]
SAMSUNG_SEANDROID
[boot/sign.rs:242] unexpected ASN.1 DER tag: expected SEQUENCE, got APPLICATION [19] (primitive)
- Checking ramdisk status
- Stock boot image detected
- Patching ramdisk
resetprop: get prop [ro.crypto.state]: [unencrypted]
preinit device: USERDATA
- Pre-init storage partition: USERDATA
[boot/cpio.rs:406] Value too large for defined data type (os error 75)
[boot/cpio.rs:634] Failed to process cpio
! Unable to patch ramdisk
! Installation failed
canyie commented 7 months ago

Can you try the latest CI build and see if the issue is resolved? https://github.com/topjohnwu/Magisk/actions/runs/8855504814

Unknown78 commented 7 months ago

@canyie The App was crashed right after I tap LET'S GO. logcat_Magisk_27002_33b7b8b_app-debug_2024-04-28T15.48.53.131000.txt

04-28 15:48:56.393 19567 19567 E App     : kotlin.UninitializedPropertyAccessException: lateinit property installDir has not been initialized
04-28 15:48:56.393 19567 19567 E App     :  at com.topjohnwu.magisk.core.tasks.MagiskInstallImpl.getInstallDir(MagiskInstaller.kt:58)
04-28 15:48:56.393 19567 19567 E App     :  at com.topjohnwu.magisk.core.tasks.MagiskInstaller.exec$suspendImpl(MagiskInstaller.kt:576)
04-28 15:48:56.393 19567 19567 E App     :  at com.topjohnwu.magisk.core.tasks.MagiskInstaller$exec$1.invokeSuspend(MagiskInstaller.kt)
04-28 15:48:56.393 19567 19567 E App     :  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
04-28 15:48:56.393 19567 19567 E App     :  at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
04-28 15:48:56.393 19567 19567 E App     :  at android.os.Handler.handleCallback(Handler.java)
04-28 15:48:56.393 19567 19567 E App     :  at android.os.Handler.dispatchMessage(Handler.java)
04-28 15:48:56.393 19567 19567 E App     :  at android.os.Looper.loop(Looper.java)
04-28 15:48:56.393 19567 19567 E App     :  at android.app.ActivityThread.main(ActivityThread.java)
04-28 15:48:56.393 19567 19567 E App     :  at java.lang.reflect.Method.invoke(Native Method)
04-28 15:48:56.393 19567 19567 E App     :  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
04-28 15:48:56.393 19567 19567 E App     :  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
04-28 15:48:56.393 19567 19567 E App     :  Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@906538d, Dispatchers.Main.immediate]
canyie commented 7 months ago

I tried locally patching the provided boot image, and it works just fine here, with both arm64-v8a and armeabi-v7a ABIs. 🤔

- Device platform: arm64-v8a
- Installing: 33b7b8b2 (27002)
- Copying image to cache
Parsing boot image: [/data/user_de/0/com.topjohnwu.magisk/install/boot.img]
HEADER_VER      [0]
- Unpacking boot image
KERNEL_SZ       [4820240]
RAMDISK_SZ      [3080446]
SECOND_SZ       [0]
EXTRA_SZ        [1099776]
OS_VERSION      [7.1.1]
OS_PATCH_LEVEL  [2019-01]
PAGESIZE        [2048]
NAME            [SYSMAGIC000KU]
CMDLINE         [buildvariant=userdebug]
CHECKSUM        [293d6aa103784032660708f460290ca0ea8eb751000000000000000000000000]
! Could not find zImage gzip piggy, keeping raw kernel
KERNEL_FMT      [zimage]
RAMDISK_FMT     [gzip]
EXTRA_FMT       [raw]
SAMSUNG_SEANDROID
[boot/sign.rs:261] unexpected ASN.1 DER tag: expected SEQUENCE, got APPLICATION [19] (primitive)
- Checking ramdisk status
Loading cpio: [ramdisk.cpio]
- Stock boot image detected
- Patching ramdisk
resetprop: get prop [ro.crypto.state]: [encrypted]
- Pre-init storage partition: sda8
Loading cpio: [ramdisk.cpio]
Add file [init] (100750)
Create directory [overlay.d] (0750)
Create directory [overlay.d/sbin] (0750)
Add file [overlay.d/sbin/magisk.xz] (100644)
Add file [overlay.d/sbin/stub.xz] (100644)
Patch with flag KEEPVERITY=[true] KEEPFORCEENCRYPT=[true]
Loading cpio: [ramdisk.cpio.orig]
Backup [init] -> [.backup/init.xz]
Record new entry: [overlay.d] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/magisk.xz] -> [.backup/.rmlist]
Record new entry: [overlay.d/sbin/stub.xz] -> [.backup/.rmlist]
Create directory [.backup] (0000)
Add file [.backup/.magisk] (100000)
Dumping cpio: [ramdisk.cpio]
Loading dtbs from [extra]
Loading dtbs from [extra]
- Repacking boot image
Parsing boot image: [/data/user_de/0/com.topjohnwu.magisk/install/boot.img]
HEADER_VER      [0]
KERNEL_SZ       [4820240]
RAMDISK_SZ      [3080446]
SECOND_SZ       [0]
EXTRA_SZ        [1099776]
OS_VERSION      [7.1.1]
OS_PATCH_LEVEL  [2019-01]
PAGESIZE        [2048]
NAME            [SYSMAGIC000KU]
CMDLINE         [buildvariant=userdebug]
CHECKSUM        [293d6aa103784032660708f460290ca0ea8eb751000000000000000000000000]
! Could not find zImage gzip piggy, keeping raw kernel
KERNEL_FMT      [zimage]
RAMDISK_FMT     [gzip]
EXTRA_FMT       [raw]
SAMSUNG_SEANDROID
[boot/sign.rs:261] unexpected ASN.1 DER tag: expected SEQUENCE, got APPLICATION [19] (primitive)
Repack to boot image: [new-boot.img]
HEADER_VER      [0]
KERNEL_SZ       [4820240]
RAMDISK_SZ      [3230107]
SECOND_SZ       [0]
EXTRA_SZ        [1099776]
OS_VERSION      [7.1.1]
OS_PATCH_LEVEL  [2019-01]
PAGESIZE        [2048]
NAME            [SYSMAGIC000KU]
CMDLINE         [buildvariant=userdebug]
CHECKSUM        [dba84c228351752b5430171bb48538ddb8f7ec0f000000000000000000000000]

****************************
 Output file is written to
 /storage/emulated/0/Download/magisk_patched-27002_OHsIl.img
****************************
- All done!
- 
Unknown78 commented 7 months ago

@canyie

33b7b8b2 (27002)

Does the local one Method named Select and Patch a File? If yes, then it's also failed in mine with 33b7b8b2 (27002)

magisk_install_log_2024-05-03T03.27.28.log

- Device platform: armeabi-v7a
- Installing: 33b7b8b2 (27002)
- Copying image to cache
! Installation failed

I was able to do root things like adb shell su, which I've previously granted in 27001 (3d91a561). In 33b7b8b2 (27002), it seems like the App itself has trouble gaining root access.

I've tried the new build of 4dc1c59 (27002) https://github.com/topjohnwu/Magisk/actions/runs/8889713910 and it's still the same.

logcat_Magisk_27002_4dc1c59_app-debug_2024-05-03T06.41.10.217000.txt It might be related to the previous logcat https://github.com/topjohnwu/Magisk/issues/8013#issuecomment-2081398287 There's seems to be a lot of error in the logcat like this:

05-03 06:41:11.813  3385  7582 E ActivityTrigger: activityStartTrigger: not whiteListedcom.topjohnwu.magisk/com.topjohnwu.magisk.ui.MainActivity/27002
Screenshot (click to expand) ![screenshot-2024_05_03_03_35_37](https://github.com/topjohnwu/Magisk/assets/25132599/3ab2f946-cc18-49bb-bc76-a45af198393f)

I could click the save button, and here's the log: magisk_log_2024-05-03T06.41.30.log


81658d45 (27002)

If I rollback the App to the 81658d45 (27002), then the Select and Patch a File method is also fail.

magisk_install_log_2024-05-03T03.43.33.log

- Device platform: armeabi-v7a
- Installing: 81658d45 (27002)
- Copying image to cache
- Unpacking boot image
Parsing boot image: [/data/user_de/0/com.topjohnwu.magisk/install/boot.img]
HEADER_VER      [0]
KERNEL_SZ       [4820240]
RAMDISK_SZ      [3080446]
SECOND_SZ       [0]
EXTRA_SZ        [1099776]
OS_VERSION      [7.1.1]
OS_PATCH_LEVEL  [2019-01]
PAGESIZE        [2048]
NAME            [SYSMAGIC000KU]
CMDLINE         [buildvariant=userdebug]
CHECKSUM        [293d6aa103784032660708f460290ca0ea8eb751000000000000000000000000]
! Could not find zImage gzip piggy, keeping raw kernel
KERNEL_FMT      [zimage]
RAMDISK_FMT     [gzip]
EXTRA_FMT       [raw]
SAMSUNG_SEANDROID
[boot/sign.rs:242] unexpected ASN.1 DER tag: expected SEQUENCE, got APPLICATION [19] (primitive)
- Checking ramdisk status
- Stock boot image detected
- Patching ramdisk
resetprop: get prop [ro.crypto.state]: [unencrypted]
preinit device: USERDATA
- Pre-init storage partition: USERDATA
[boot/cpio.rs:406] Value too large for defined data type (os error 75)
[boot/cpio.rs:634] Failed to process cpio
! Unable to patch ramdisk
! Installation failed

So it seems like there's a different bug in the latest CI build that should be opened in a new issue? Instead of solving this one, we've found another one. That's great. 🤣

Unknown78 commented 7 months ago

@eduardomoguel what?

Unknown78 commented 7 months ago

@canyie

Based on https://github.com/topjohnwu/Magisk/actions/workflows/build.yml?page=2&query=event%3Apush There's seems to be 18 builds between 27001 and 27002, do you want me to find which one causes fault by trying it one by one?

Spoiler (click to expand) > Release new canary build > Magisk Build #4003: Commit 83209b2 pushed by topjohnwu > > Support tar with files larger than 8GiB > Magisk Build #3998: Commit 81658d4 pushed by topjohnwu > > Upgrade AGP > Magisk Build #3986: Commit 19ea25a pushed by topjohnwu > > Ensure stub APK is expected > Magisk Build #3984: Commit dbf6e40 pushed by topjohnwu > > Add no decompression flag to magiskboot split > Magisk Build #3973: Commit 991802a pushed by topjohnwu > > Improve Turkish language translation > Magisk Build #3971: Commit 7f6b530 pushed by topjohnwu > > Reverse format template argument order > Magisk Build #3970: Commit 825c6c4 pushed by topjohnwu > > Update crt0 > Magisk Build #3967: Commit a6ff367 pushed by topjohnwu > > Fix segfault when sepolicy.rule has empty line > Magisk Build #3960: Commit 2290dde pushed by topjohnwu > > Update crt0 > Magisk Build #3959: Commit 74af79a pushed by topjohnwu > > No more sony init.real tricks > Magisk Build #3955: Commit b6c24a3 pushed by topjohnwu > > Build magiskboot with crt0 > Magisk Build #3954: Commit 24e46a5 pushed by topjohnwu > > Reorganize code > Magisk Build #3952: Commit 715284b pushed by topjohnwu > > Use self implemented parse_mount_info > Magisk Build #3951: Commit 62fc786 pushed by topjohnwu > > Replace all parse_mount_info usage with Rust > Magisk Build #3949: Commit 1a70796 pushed by topjohnwu > > Make crt0 an external submodule > Magisk Build #3948: Commit 8f7d2e3 pushed by topjohnwu > > Update ONDK > Magisk Build #3939: Commit 7e9abe6 pushed by topjohnwu > > Prompt users to use reboot button in System Updates > Magisk Build #3933: Commit 4d5510b pushed by topjohnwu > > Rename DownloadManager to DownloadEngine > Magisk Build #3911: Commit 2aa9231 pushed by topjohnwu > > Release new canary build > Magisk Build #3908: Commit 154121f pushed by topjohnwu > > Release Magisk v27.0 > Magisk Build #3907: Commit 2c6adbc pushed by topjohnwu
yujincheng08 commented 5 months ago

should be fixed by https://github.com/topjohnwu/Magisk/commit/2e4440b7025c262f6b36cf55ea0c69532e17f905 and https://github.com/topjohnwu/crt0/commit/f7f43a51a998f31e6fc22622ace5d9bb1026c3e4

Unknown78 commented 5 months ago

@yujincheng08 That's commit from 10th April, It's older than when I opened this issue.

yujincheng08 commented 5 months ago

The commit you used when you opened this issue is 81658d45f7236fdbd535a6c3a06ae19bc08cb842, which is from Mar 15

Unknown78 commented 5 months ago

@yujincheng08 clearly you haven't read the subsequent comment, I did test the Apr 27 commit, https://github.com/topjohnwu/Magisk/issues/8013#issuecomment-2091532113 I haven't tested the currently latest build though.

yujincheng08 commented 5 months ago

I read, but what you show later is another issue.