FS#79847 - [android-tools] Fastboot terminating with an std::out_of_range exception

Attached to Project: Arch Linux
Opened by Nathaniel Barragan (NateDogg1232) - Wednesday, 04 October 2023, 00:26 GMT
Last edited by Toolybird (Toolybird) - Wednesday, 04 October 2023, 06:00 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Anatol Pomozov (anatolik)
Filipe Laíns (FFY00)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
When flashing using fastboot this error occurs:

```
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::compare: __pos (which is 464) > this->size() (which is 0)

Aborted (core dumped)
```

After looking into the backtrace, this seems to happen at `copy_avb_footer` in fastboot.cpp:1214

This bug does NOT happen with platform tools downloaded straight from the Android SDK (I got it using Android Studio).

Additional info:
* package version(s): 34.0.4-2
* config and/or log files etc.: N/A.
* link to upstream bug report, if any: There *seems* to be one here, but it's dead. https://issuetracker.google.com/issues/284335462

Steps to reproduce:
Get any sort of fastboot image
Flash that to a specific partition

In my case, this was:
$ adb reboot bootloader
$ fastboot flash userdata asteroid-image-bass.ext4
$ # Error here
This task depends upon

Closed by  Toolybird (Toolybird)
Wednesday, 04 October 2023, 06:00 GMT
Reason for closing:  Duplicate
Additional comments about closing:  Merged into  FS#79685 
Comment by Toolybird (Toolybird) - Wednesday, 04 October 2023, 03:55 GMT
> Aborted (core dumped)

Please post a backtrace containing debug information [1][2]. It's usually as simple as:

$ coredumpctl gdb (then answer y when it asks "Enable debuginfod for this session?")
(gdb) set logging enabled
(gdb) bt (or bt full)

Then post gdb.txt

See also  FS#79685 . A comment there mentions possible cause as -Wp,-D_GLIBCXX_ASSERTIONS. Please try recompiling the pkg with that removed from CFLAGS and see if it still crashes?

[1] https://wiki.archlinux.org/title/Debugging/Getting_traces
[2] https://blogs.gnome.org/mcatanzaro/2021/09/18/creating-quality-backtraces-for-crash-reports/
Comment by Nathaniel Barragan (NateDogg1232) - Wednesday, 04 October 2023, 05:31 GMT
Attached is the gdb.txt file. I'll test the package with -Wp,-D_GLIBCXX_ASSERTIONS flags and let you know.
   gdb.txt (4.2 KiB)
Comment by Nathaniel Barragan (NateDogg1232) - Wednesday, 04 October 2023, 05:44 GMT
Yes I can confirm that recompiling with those flags removed fixes the problem.

I set CXXFLAGS to be my default CXXFLAGS without those two, and that worked perfectly.

The CXX flags that were set are as follows:
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection"


Comment by Toolybird (Toolybird) - Wednesday, 04 October 2023, 05:59 GMT
> recompiling with those flags removed fixes the problem

It likely explains why the Android SDK version doesn't crash, but it still suggests the upstream code is buggy and needs to be fixed. Just papering over asserts is no proper solution. Please report it upstream. I'll merge this into the other ticket because it seems to be the same root cause.

Loading...