Test test_arsc.py::test_differences fails on armhf

Bug #2026151 reported by Danilo Egea Gondolfo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
diffoscope (Ubuntu)
New
Undecided
Unassigned

Bug Description

Autopkgtests will fail on armhf.

See logs attached.

Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :
Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

The command diffoscope resources1.arsc resources2.arsc fails on an armhf containers running on arm64.

root@optimum-quagga:~/diffoscope/tests/data# diffoscope resources1.arsc resources2.arsc
--- resources1.arsc
+++ resources2.arsc
│┄ Command `'aapt2 dump resources {}'` failed with exit code -7. (No output)
@@ -1,15 +1,15 @@
 00000000: 0200 0c00 4804 0000 0100 0000 0100 1c00 ....H...........
 00000010: b400 0000 0500 0000 0000 0000 0001 0000 ................
-00000020: 3000 0000 0000 0000 0000 0000 0d00 0000 0...............
-00000030: 3800 0000 5000 0000 6d00 0000 0a0a 536f 8...P...m.....So
-00000040: 6b6f 6261 6e28 6729 0028 2861 3531 3962 koban(g).((a519b
-00000050: 3331 3062 6366 6162 3038 3232 3738 3838 310bcfab08227888
-00000060: 3432 3461 3431 3265 3462 3265 3738 3165 424a412e4b2e781e
-00000070: 3164 6100 1515 7265 732f 6472 6177 6162 1da...res/drawab
+00000020: 3000 0000 0000 0000 0000 0000 2b00 0000 0...........+...
+00000030: 3800 0000 5000 0000 6d00 0000 2828 3362 8...P...m...((3b
+00000040: 6435 3938 3762 3164 3066 6165 6262 6464 d5987b1d0faebbdd
+00000050: 3736 3734 3561 6664 6265 3939 3264 6362 76745afdbe992dcb
+00000060: 3333 3163 3733 000a 0a53 6f6b 6f62 616e 331c73...Sokoban
+00000070: 2867 2900 1515 7265 732f 6472 6177 6162 (g)...res/drawab
 00000080: 6c65 2f69 636f 6e2e 706e 6700 1a1a 7265 le/icon.png...re
 00000090: 732f 6472 6177 6162 6c65 2f70 7265 7370 s/drawable/presp
 000000a0: 6c61 7368 2e6a 7067 0013 1372 6573 2f6c lash.jpg...res/l
 000000b0: 6179 6f75 742f 6d61 696e 2e78 6d6c 0000 ayout/main.xml..
 000000c0: 0002 2001 8803 0000 7f00 0000 6400 6500 .. .........d.e.
 000000d0: 7600 2e00 6f00 6200 6600 7500 7300 6b00 v...o.b.f.u.s.k.
 000000e0: 2e00 7300 6f00 6b00 6f00 6200 6100 6e00 ..s.o.k.o.b.a.n.
@@ -61,9 +61,9 @@
 000003c0: 0200 0000 0000 0000 0000 0000 0102 5400 ..............T.
 000003d0: 7c00 0000 0300 0000 0200 0000 5c00 0000 |...........\...
 000003e0: 4000 0000 0000 0000 0000 0000 0000 0000 @...............
 000003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
 00000400: 0000 0000 0000 0000 0000 0000 0000 0000 ................
 00000410: 0000 0000 0000 0000 0000 0000 0000 0000 ................
 00000420: 0000 0000 1000 0000 0800 0000 0300 0000 ................
-00000430: 0800 0003 0000 0000 0800 0000 0400 0000 ................
-00000440: 0800 0003 0100 0000 ........
+00000430: 0800 0003 0100 0000 0800 0000 0400 0000 ................
+00000440: 0800 0003 0000 0000 ........

The expected output is something like this:

--- resources1.arsc
+++ resources2.arsc
├── aapt2 dump resources {}
│ @@ -8,8 +8,8 @@
│ type layout id=02 entryCount=1
│ resource 0x7f020000 layout/main
│ () (file) res/layout/main.xml type=XML
│ type string id=03 entryCount=2
│ resource 0x7f030000 string/app_name
│ () "Sokoban(g)"
│ resource 0x7f030001 string/private_version
│ - () "a519b310bcfab08227888424a412e4b2e781e1da"
│ + () "3bd5987b1d0faebbdd76745afdbe992dcb331c73"

On native armhf it works.

Revision history for this message
Mattia Rizzolo (mapreri) wrote :

Would you be able to run that `aapt2 dump resources` on a failing host? Since the output implies that this is failing to run the command. I wonder if this is some kind of bus fault or whatever the error was with emulating armhf on arm64.

Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :
Download full text (4.9 KiB)

eh, there you go, aapt2 is indeed crashing

root@optimum-quagga:~/diffoscope# gdb --args aapt2 dump resources /tmp/tmpntfkh146/out.apk
GNU gdb (Ubuntu 13.2-1ubuntu1) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from aapt2...
Reading symbols from /usr/lib/debug/.build-id/08/4ab3c604520da0c8ff77de341641ed94213b9d.debug...
(gdb) r
Starting program: /usr/bin/aapt2 dump resources /tmp/tmpntfkh146/out.apk
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".

Program received signal SIGBUS, Bus error.
android::ResTable_config::copyFromDeviceNoSwap (this=0xfffee6b0, o=...) at ./libs/androidfw/ResourceTypes.cpp:1838
1838 ./libs/androidfw/ResourceTypes.cpp: No such file or directory.
(gdb) bt
#0 android::ResTable_config::copyFromDeviceNoSwap (this=0xfffee6b0, o=...) at ./libs/androidfw/ResourceTypes.cpp:1838
#1 android::ResTable_config::copyFromDtoH (this=0xfffee6b0, o=...) at ./libs/androidfw/ResourceTypes.cpp:1911
#2 0x004b4a28 in aapt::BinaryResourceParser::ParseType (this=this@entry=0xfffeed58, package=package@entry=0x5bc8a8, chunk=0xf7fcf709) at ./tools/aapt2/format/binary/BinaryResourceParser.cpp:352
#3 0x004b3928 in aapt::BinaryResourceParser::ParsePackage (this=this@entry=0xfffeed58, chunk=<optimized out>) at ./tools/aapt2/format/binary/BinaryResourceParser.cpp:241
#4 0x004b2ff4 in aapt::BinaryResourceParser::ParseTable (this=this@entry=0xfffeed58, chunk=<optimized out>) at ./tools/aapt2/format/binary/BinaryResourceParser.cpp:156
#5 0x004b2914 in aapt::BinaryResourceParser::Parse (this=0xfffeed58) at ./tools/aapt2/format/binary/BinaryResourceParser.cpp:109
#6 0x00511054 in aapt::LoadedApk::LoadBinaryApkFromFileCollection (source=..., collection=std::unique_ptr<aapt::io::IFileCollection> = {...}, diag=diag@entry=0xfffef338) at ./tools/aapt2/LoadedApk.cpp:168
#7 0x00510844 in aapt::LoadedApk::LoadApkFromPath (path=..., diag=0xfffef338) at ./tools/aapt2/LoadedApk.cpp:87
#8 0x00428b18 in aapt::DumpApkCommand::Action (this=0x5ba290, args=...) at tools/aapt2/cmd/Dump.h:72
#9 0x00413440 in aapt::Command::Execute (this=0x5ba290, args=..., out_error=<optimized out>) at ./tools/aapt2/cmd/Command.cpp:250
#10 0x00413548 in aapt::Command::Execute (this=0x5b7eb8, args=..., out_error=<optimized out>) at ./tools/aapt2/cmd/Command.cpp:200
#11 0x00413548 in aapt::Command::Execute (this=0x5b5a40, args=..., out_error=<optimized out>) at ./tools/aapt2/cmd/Command.cpp:200
#12 0x00552dd0 in MainImpl (argc=<optimized out>, a...

Read more...

Revision history for this message
Mattia Rizzolo (mapreri) wrote (last edit ):

So I guess this should be filed against aapt, I reported it on Debian here https://bugs.debian.org/1040409

Could you please verify whether `aapt --version` also fails, or whether it returns 0? I'm thinking of adding a check on diffoscope to verify aapt works before using it, but I'd rather have a "simpler" command to test.

Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

aapt --version and aapt2 version just works. The problem appears to be inside /usr/lib/arm-linux-gnueabihf/android/libandroidfw.so.

Digging a bit more, the code crashes here:

#0 android::ResTable_config::copyFromDeviceNoSwap (this=0xfffee6a0, o=...)
    at ./libs/androidfw/ResourceTypes.cpp:1838

1835 void ResTable_config::copyFromDeviceNoSwap(const ResTable_config& o) {
1836 const size_t size = dtohl(o.size);
1837 if (size >= sizeof(ResTable_config)) {
1838 *this = o;
1839 } else {
1840 memcpy(this, &o, size);
1841 memset(((uint8_t*)this)+size, 0, sizeof(ResTable_config)-size);
1842 }

The exact instruction is loading the contents of some registers to the address stored in r1

0xf7eb95d8 <+20>: ldm r1!, {r2, r3, r4, r5, r6}

Here is the value of r1:

(gdb) i r r1
r1 0xf7fcf71d 4160550685

This address is where the .apk file is mapped to? o.O what...

f7fcf000-f7fd0000 r--s 00000000 fc:10 25777288 /tmp/tmpntfkh146/out.apk

And it is not writable, what explain the bus error.

The package with this code is android-libandroidfw.

Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

Wait, it's the other way around, it's load from *r1 to those registers... so loading from the file.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.