Hi,

On Sun, Feb 14, 2021 at 02:12:17PM +0000, Vincent Arkesteijn wrote:
> Firefox is killed with SIGILL shortly after startup:
> $ firefox-esr -safe-mode
> Illegal instruction
> $ 

This is due to the fact that some armhf CPUs do not have support for NEON
instructions.

skia used to detect such support at runtime, but that behavior was removed in
https://github.com/google/skia/commit/809ccf37ec836d0df64afd0b13023fd968d505a4

Firefox seems to erroneously enable NEON in places where it shouldn't. Trying
to figure out exactly where and what's the best way to address this.

Meanwhile, to reproduce and debug this issue on a amd64 machine:

  apt install debootstrap qemu-user-static binfmt-support schroot

Trying to run a armhf binary on the x86 host will invoke qemu-arm-static, see:

  /usr/sbin/update-binfmts --display qemu-arm
  ls -l /usr/libexec/qemu-binfmt/arm-binfmt-P

Create a armhf chroot:

  debootstrap --arch=armhf sid /srv/sid-armhf
  printf '[armhf]\ntype=directory\ndirectory=/srv/sid-armhf\n' >> 
/etc/schroot/schroot.conf

Install and run firefox-esr in the chroot:

  schroot -c armhf
  (armhf)root@ariel:/home/ema# apt install --no-install-recommends firefox-esr

Firefox seems to be working:

  (armhf)root@ariel:/home/ema# firefox --help | head -1
  Usage: firefox-esr [ options ... ] [URL]

The reason why firefox does not crash here is that the default armhf CPU
emulated by qemu-arm-static has NEON support. We can override that by setting
QEMU_CPU to cortex-r5f (which cannot execute NEON instructions) and reproduce
the issue:

  (armhf)root@ariel:/home/ema# QEMU_CPU=cortex-r5f firefox
  qemu: uncaught target signal 4 (Illegal instruction) - core dumped
  Illegal instruction

To get a backtrace, install Firefox's debugging symbols in the chroot:

  (armhf)root@ariel:/home/ema# echo 'deb http://deb.debian.org/debian-debug 
sid-debug main' > /etc/apt/sources.list.d/debug.list
  (armhf)root@ariel:/home/ema# apt update && apt install firefox-esr-dbgsym

And do the following on the x86 host:

  dpkg --add-architecture armhf
  apt install libc6:armhf libc6-dbg:armhf gdb-multiarch

  LD_LIBRARY_PATH=/srv/sid-armhf/usr/lib/arm-linux-gnueabihf qemu-arm-static -g 
1234 -cpu cortex-r5f /srv/sid-armhf/usr/bin/firefox-esr --private-window

In another terminal, again on the host, this should give you a backtrace:

  gdb-multiarch -q /srv/sid-armhf/usr/bin/firefox-esr -ex 'set architecture 
arm' -ex 'target remote :1234' -ex 'set debug-file-directory 
/srv/sid-armhf/usr/lib/debug' -ex 'set pagination off' -ex 'continue' -ex 'bt' 
-ex 'continue' -ex 'exit'

Something like:

  Program received signal SIGILL, Illegal instruction.
  0x37071dc6 in _GLOBAL__sub_I_SkOpts.cpp () from 
/srv/sid-armhf/usr/lib/firefox-esr/libxul.so
  #0  0x37071dc6 in _GLOBAL__sub_I_SkOpts.cpp () from 
/srv/sid-armhf/usr/lib/firefox-esr/libxul.so
  #1  0x3f7d144c in call_init (env=0x3f208340, argv=0x3ffffc94, argc=1, 
l=<optimized out>) at dl-init.c:70
  #2  call_init (l=<optimized out>, argc=1, argv=0x3ffffc94, env=0x3f208340) at 
dl-init.c:26
  #3  0x3f7d14f2 in _dl_init (main_map=0x3f245f00, argc=1, argv=0x3ffffc94, 
env=0x3f208340) at dl-init.c:117
  #4  0x3f56664a in _dl_catch_exception () from 
/srv/sid-armhf/usr/lib/arm-linux-gnueabihf/libc.so.6
  #5  0x3f7d5b60 in dl_open_worker (a=0x3fffd7b0) at dl-open.c:808
  #6  0x3f566614 in _dl_catch_exception () from 
/srv/sid-armhf/usr/lib/arm-linux-gnueabihf/libc.so.6
  #7  0x3f7d5da2 in _dl_open (file=0x3fffda64 
"/srv/sid-armhf/usr/lib/firefox-esr/libxul.so", mode=-2147483391, 
      caller_dlopen=0x4000af81 <_start+4560>, nsid=-2, argc=1, argv=0x3ffffc94, 
env=0x3f208340) at dl-open.c:884
  #8  0x3f4d9da0 in ?? () from 
/srv/sid-armhf/usr/lib/arm-linux-gnueabihf/libc.so.6

Reply via email to