Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 633532 - app-emulation/qemu: Segmentation fault when running certain commands
Summary: app-emulation/qemu: Segmentation fault when running certain commands
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo QEMU Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-05 06:40 UTC by Tamas Jantvik
Modified: 2018-02-11 18:42 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tamas Jantvik 2017-10-05 06:40:32 UTC
I want to use QEMU to emulate a RaspberryPi ArchLinuxArm environment. 

I set up my environment like:
CHROOT_IMAGE="alarmpi1.img"
CHROOT_LOCATION="alarmpi1"
dd of="${CHROOT_IMAGE}" bs=1 seek=16G count=0 && \
/sbin/mkfs.ext4 -m 0 -L 'rootfs' -F "${CHROOT_IMAGE}" && \
mkdir -m0700 "${CHROOT_LOCATION}" && touch -t 197001010100 "${CHROOT_LOCATION}" && \
sudo mount -t ext4 -o defaults,rw,nodiratime,noatime,user_xattr -v "${CHROOT_IMAGE}" "${CHROOT_LOCATION}" && \
( [[ -f "ArchLinuxARM-rpi-latest.tar.gz" ]] || wget 'http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz' ) && \
[[ -f "ArchLinuxARM-rpi-latest.tar.gz" ]] && \
findmnt "${CHROOT_LOCATION}" &> /dev/null && \
( cd "${CHROOT_LOCATION}" && sudo -- bash -c "ROOT=\"${PWD}/\" emerge -1qv --usepkgonly --nodeps app-emulation/qemu" )

QEMU is installed as:
[I] app-emulation/qemu
     Installed versions:  2.10.0{tbz2}(13:48:54 2017-10-03)(aio alsa bluetooth bzip2 caps curl fdt filecaps gnutls gtk iscsi jpeg lzo ncurses nfs nls opengl pin-upstream-blobs png pulseaudio python sasl sdl sdl2 seccomp smartcard snappy spice ssh static-user tci usb usbredir vde vhost-net virgl virtfs vnc xattr xfs -accessibility -debug -glusterfs -gtk2 -infiniband -numa -rbd -selinux -static -systemtap -test -vte -xen KERNEL="linux -FreeBSD" LINGUAS="bg de_DE fr_FR hu it tr zh_CN" PYTHON_TARGETS="python2_7" QEMU_SOFTMMU_TARGETS="aarch64 alpha arm cris i386 lm32 m68k microblaze microblazeel mips mips64 mips64el mipsel moxie nios2 or1k ppc ppc64 ppcemb s390x sh4 sh4eb sparc sparc64 tricore unicore32 x86_64 xtensa xtensaeb" QEMU_USER_TARGETS="aarch64 alpha arm armeb cris hppa i386 m68k microblaze microblazeel mips mips64 mips64el mipsel mipsn32 mipsn32el nios2 or1k ppc ppc64 ppc64abi32 ppc64le s390x sh4 sh4eb sparc sparc32plus sparc64 tilegx x86_64")
     Homepage:            http://www.qemu.org http://www.linux-kvm.org
     Description:         QEMU + Kernel-based Virtual Machine userland tools

I then enter the environment:
( findmnt "${CHROOT_LOCATION}" &> /dev/null || sudo mount -t ext4 -o defaults,rw,nodiratime,noatime,user_xattr -v alarmpi1.img "${CHROOT_LOCATION}" ) && \
( gcc -static qemu-wrapper--arm1176jz-s.c -O3 -s -o qemu-wrapper--arm1176jz-s && sudo mv -v qemu-wrapper--arm1176jz-s "${CHROOT_LOCATION}/usr/bin"/ && sudo chown 0:0 "${CHROOT_LOCATION}/usr/bin/qemu-wrapper--arm1176jz-s" ) &&
( findmnt "${CHROOT_LOCATION}/dev" &> /dev/null || sudo mount -o rbind -v /dev "${CHROOT_LOCATION}/dev" ) && \
( findmnt "${CHROOT_LOCATION}/proc" &> /dev/null || sudo mount -t proc -v none "${CHROOT_LOCATION}/proc" ) && \
( findmnt "${CHROOT_LOCATION}/sys" &> /dev/null || sudo mount -o bind -v /sys "${CHROOT_LOCATION}/sys" ) && \
( findmnt "${CHROOT_LOCATION}/tmp" &> /dev/null || sudo mount -o bind -v /tmp "${CHROOT_LOCATION}/tmp" ) && \
sudo rm -fv "${CHROOT_LOCATION}/etc/resolv.conf" && \
sudo cp -av /etc/resolv.conf "${CHROOT_LOCATION}/etc/" &&
sudo chroot "${CHROOT_LOCATION}" /bin/bash --login

The wrapper points to the qemu binary, of course. And qemu-binfmt is pointing to the wrapper. I do have a working ls, for instance:

[root@machine /]# ls -al
total 68
drwxr-xr-x  17 root root  4096 Oct  5 06:05 .
drwxr-xr-x  17 root root  4096 Oct  5 06:05 ..
lrwxrwxrwx   1 root root     7 Apr  1  2017 bin -> usr/bin
drwxr-xr-x   3 root root  4096 Sep 10 16:32 boot
drwxr-xr-x  24 root root  6920 Oct  4 15:46 dev
drwxr-xr-x  43 root root  4096 Oct  5 06:14 etc
drwxr-xr-x   3 root root  4096 Sep 10 16:33 home
lrwxrwxrwx   1 root root     7 Apr  1  2017 lib -> usr/lib
drwx------   2 root root 16384 Oct  5 06:02 lost+found
drwxr-xr-x   2 root root  4096 Apr  1  2017 mnt
drwxr-xr-x   3 root root  4096 Sep 10 16:32 opt
dr-xr-xr-x 500 root root     0 Oct  4 15:43 proc
drwxr-x---   3 root root  4096 Sep 10 16:32 root
drwxr-xr-x   2 root root  4096 Sep 10 16:32 run
lrwxrwxrwx   1 root root     7 Apr  1  2017 sbin -> usr/bin
drwxr-xr-x   4 root root  4096 Sep 10 16:32 srv
dr-xr-xr-x  12 root root     0 Oct  4 15:44 sys
drwxrwxrwt  34 root root  4096 Oct  5 06:14 tmp
drwxr-xr-x  10 root root  4096 Oct  5 06:09 usr
drwxr-xr-x  12 root root  4096 Sep 10 16:32 var

But, running pacman leads to a segmentation fault:

[root@machine /]# pacman -Syy
:: Synchronizing package databases...

error: segmentation fault
Please submit a full bug report with --debug if appropriate.

If I however exchange the last line of the environment setup to:
sudo cp -av /usr/bin/qemu-arm-static "${CHROOT_LOCATION}/usr/bin"/
where the static binary is Debian's (https://raw.githubusercontent.com/tsjk/gentoo-ebuilds/master/app-emulation/qemu-user-static-bin/qemu-user-static-bin-2.10.0_p1.ebuild) and re-point the wrapper, then all is well:

[root@machine /]# pacman -Syy
:: Synchronizing package databases...
 core                                                                                                                                     176.9 KiB  1291K/s 00:00 [#####################################################################################################] 100%
 extra                                                                                                                                      2.1 MiB  1516K/s 00:01 [#####################################################################################################] 100%
 community                                                                                                                                  3.9 MiB  2.53M/s 00:02 [#####################################################################################################] 100%
 alarm                                                                                                                                     38.4 KiB   800K/s 00:00 [#####################################################################################################] 100%
 aur                                                                                                                                        7.6 KiB  3.73M/s 00:00 [#####################################################################################################] 100%

What could be wrong here? And what more can I do to aid resolution?
Comment 1 Matthias Maier gentoo-dev 2017-11-12 20:48:16 UTC
Can you reproduce with qemu-2.10.1?
Comment 2 Joakim Tjernlund 2017-12-09 17:37:36 UTC
This could be a glibc issue as well, what glibc did you resp. debian use?

BTW, if you use the binfmt flag F you don't need to copy /usr/bin/qemu-arm-static
around.
Comment 3 Tamas Jantvik 2017-12-09 22:57:04 UTC
I'll take another look soon then. Been busy, but haven't forgotten this.
Comment 4 Matthias Maier gentoo-dev 2018-02-11 18:42:33 UTC
Please reopen if you can reproduce.