Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Regression: sparseResources is always true #3199

Closed
IgorEisberg opened this issue Jul 23, 2023 · 2 comments · Fixed by #3201
Closed

[BUG] Regression: sparseResources is always true #3199

IgorEisberg opened this issue Jul 23, 2023 · 2 comments · Fixed by #3201
Labels
Milestone

Comments

@IgorEisberg
Copy link
Contributor

Another issue that seems to be a regression since 2.8.0: sparseResources in apktool.yml is forced to true regardless of whether the original APK used sparse or not.
It's easy to reproduce:

  1. Decompile any APK: sparseResources is true in apktool.yml.
  2. Set sparseResources to false in apktool.yml.
  3. Recompile the APK.
  4. Decompile the rebuilt APK: sparseResources is true in apktool.yml again.

This wasn't the behavior in Apktool 2.7.1-SNAPSHOT and prior.
While it would still work when rebuilding APKs on an Android 13 ROM, no such luck on Android 10 (other versions might be affected as well), as it causes a nasty boot failure:

W /system/bin/idmap2: failed to create idmap for overlay apk path "/product/overlay/FrameworksResCommonQva.apk": overlay "/product/overlay/FrameworksResCommonQva.apk" does not successfully overlay any resource -> failed to create idmap
F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7c2f611507 in tid 2172 (idmap2), pid 2172 (idmap2)
I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
I /system/bin/tombstoned: received crash request for pid 2172
I crash_dump64: performing dump of process 2172 (target tid = 2172)
F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
F DEBUG   : Build fingerprint: 'Xiaomi/dipper/dipper:10/QKQ1.190828.002/V12.5.2.0.QEACNXM:user/release-keys'
F DEBUG   : Revision: '0'
F DEBUG   : ABI: 'arm64'
F DEBUG   : Timestamp: 2023-07-23 00:33:43+0300
F DEBUG   : pid: 2172, tid: 2172, name: idmap2  >>> /system/bin/idmap2 <<<
F DEBUG   : uid: 0
F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7c2f611507
F DEBUG   :     x0  000000000000216d  x1  0000007c2f229320  x2  0000007c2f200000  x3  0000000000000003
F DEBUG   :     x4  0000000000000029  x5  7365616d6c657373  x6  7373656c6d616573  x7  7f7f7f7f7f7f7f7f
F DEBUG   :     x8  0000007c2f1d09bc  x9  0000007c2f2413c0  x10 0000007c2f241338  x11 0000000000000011
F DEBUG   :     x12 00000000000002b1  x13 0000007c2f1d0a10  x14 0000007c2f1d09c0  x15 000000000044002f
F DEBUG   :     x16 0000007c2f1d14d8  x17 0000007cb095c8f0  x18 0000007cb1a7e000  x19 0000007c2f2ba600
F DEBUG   :     x20 0000000000000007  x21 0000007fe36c04c0  x22 0000007c2f2ba600  x23 0000007c2f2292f0
F DEBUG   :     x24 0000007cb0da2020  x25 0000007fe36c04da  x26 0000007c2f246180  x27 0000007c2f2462e8
F DEBUG   :     x28 0000007fe36c0524  x29 0000007fe36c04b0
F DEBUG   :     sp  0000007fe36c0490  lr  0000007caff577cc  pc  0000007caff57844
F DEBUG   : 
F DEBUG   : backtrace:
F DEBUG   :       #00 pc 0000000000043844  /system/lib64/libandroidfw.so (android::LoadedPackage::FindEntryByName(std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, std::__1::allocator<char16_t>> const&, std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, std::__1::allocator<char16_t>> const&) const+220) (BuildId: 56e62e9e87e328cab13d1b88d7c2cca0)
F DEBUG   :       #01 pc 0000000000039484  /system/lib64/libandroidfw.so (android::AssetManager2::GetResourceId(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const+1016) (BuildId: 56e62e9e87e328cab13d1b88d7c2cca0)
F DEBUG   :       #02 pc 00000000000134c0  /system/lib64/libidmap2.so (android::idmap2::Idmap::FromApkAssets(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, android::ApkAssets const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, android::ApkAssets const&, unsigned int const&, bool)+2188) (BuildId: 140835afee413473b2c971a844f42dfa)
F DEBUG   :       #03 pc 0000000000007794  /system/bin/idmap2 (Create(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)+1860) (BuildId: f14382a5540f8590c832167932481011)
F DEBUG   :       #04 pc 0000000000010194  /system/bin/idmap2 (Scan(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)+8568) (BuildId: f14382a5540f8590c832167932481011)
F DEBUG   :       #05 pc 000000000000d244  /system/bin/idmap2 (main+1400) (BuildId: f14382a5540hf8590c832167932481011)
F DEBUG   :       #06 pc 000000000006ebc4  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: f6cc5d2d702265511937b56460b37693)
E /system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_00
E asset   : failed to execute idmap2
W AssetManager: 'idmap2 --scan' failed: no static="true" overlays targeting "android" will be loaded
W /system/bin/idmap2: failed to create idmap for overlay apk path "/vendor/overlay/MiuiFrameworkResOverlay.apk": overlay "/vendor/overlay/MiuiFrameworkResOverlay.apk" does not successfully overlay any resource -> failed to create idmap
@iBotPeaches
Copy link
Owner

Thanks for the spot. I've added a regression test for now while I dig into the regression. Should make it easier to prevent this from happening in future - #3201

@iBotPeaches iBotPeaches added this to the v2.8.2 milestone Jul 23, 2023
@iBotPeaches
Copy link
Owner

Okay thanks - tracked it down. While its true I regressed it during some ARSC reworks. It wasn't even technically right back then. It was just prior looking for TYPE -> SPEC chunk order, but that is not consistent with a sparse resource build out.

The AOSP commit points at the true criteria of needing at least 1,000 resources (so I pulled the AOSP sample) and sets the type flag - aosp-mirror/platform_frameworks_base@c8f71aa#diff-089747e8c6864df42a7a3136c532d62afd64a0938a1fc6f3ef686d98faa635e4R349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants