Skip to content

qemu-x86_64: segfault when running grep on arm64 host

Host environment

  • Operating system: Gentoo
  • OS/kernel version: 6.6.13-gentoo-dist
  • Architecture: ARM64
  • QEMU flavor: qemu-x86_64
  • QEMU version: qemu-x86_64 version 8.2.1
  • QEMU command line:
    qemu-x86_64 -L /path/to/x86_64/chroot /path/to/x86_64/chroot/bin/grep

Emulated/Virtualized environment

  • Operating system: Gentoo
  • OS/kernel version: 6.6.13-gentoo-dist
  • Architecture: x86_64

Description of problem

An internal segmentation fault occurs when attempting to run grep in a Gentoo stage3 chroot

Steps to reproduce

  1. Unpack an x86_64 chroot environment (easiest way is using one of Gentoo's stage3s from https://get.gentoo.org)
  2. Run qemu-x86_64 -L /path/to/x86_64/chroot /path/to/x86_64/chroot/bin/grep

Additional information

It seems this only occurs in 8.x.x, 7.x.x does not have this segfault.

Output:

# qemu-x86_64 -L /bugs/grep-sandbox /bugs/grep-sandbox/bin/grep
qemu-x86_64: QEMU internal SIGSEGV {code=MAPERR, addr=0x20}
Segmentation fault

GDB bt:

(gdb) bt
#0  open_self_maps_2 (opaque=0xffffffffd0b0, guest_start=18446744073699065856, guest_end=<optimized out>, flags=12) at ../linux-user/syscall.c:8089
#1  0x000000000048539c in walk_memory_regions (priv=priv@entry=0xffffffffd0b0, fn=fn@entry=0x4a13e4 <open_self_maps_2>) at ../accel/tcg/user-exec.c:176
#2  0x00000000004a20bc in open_self_maps_1 (smaps=false, fd=3, env=<optimized out>) at ../linux-user/syscall.c:8112
#3  open_self_maps (cpu_env=<optimized out>, fd=3) at ../linux-user/syscall.c:8122
#4  0x00000000004aaa00 in do_guest_openat (cpu_env=cpu_env@entry=0x862050, dirfd=dirfd@entry=-100, fname=fname@entry=0x5555555776f1 "/proc/self/maps", flags=0, mode=mode@entry=0, safe=safe@entry=true)
    at ../linux-user/syscall.c:8381
#5  0x00000000004b0cc4 in do_syscall1 (cpu_env=cpu_env@entry=0x862050, num=num@entry=257, arg1=arg1@entry=4294967196, arg2=arg2@entry=93824992376561, arg3=arg3@entry=0, arg4=arg4@entry=0,
    arg5=arg5@entry=93824992373306, arg6=arg6@entry=0, arg8=0, arg7=0) at ../linux-user/syscall.c:9075
#6  0x00000000004b2770 in do_syscall (cpu_env=cpu_env@entry=0x862050, num=257, arg1=4294967196, arg2=93824992376561, arg3=0, arg4=0, arg5=93824992373306, arg6=0, arg7=arg7@entry=0, arg8=arg8@entry=0)
    at ../linux-user/syscall.c:13658
#7  0x0000000000404fdc in cpu_loop (env=env@entry=0x862050) at ../linux-user/x86_64/../i386/cpu_loop.c:242
#8  0x0000000000400d7c in main (argc=4, argv=0xffffffffed48, envp=<optimized out>) at ../linux-user/main.c:1014
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information