Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 666560 - sys-libs/glibc and sys-libs/musl fails to emerge from within a qemu-chroot (target: armv6/7 | host: x86_64) with: libsandbox/trace.c:_do_ptrace():75: failure (Function not implemented):* ISE:_do_ptrace: ptrace(PTRACE_TRACEME, ..., 0x00000000, 0x00000000)
Summary: sys-libs/glibc and sys-libs/musl fails to emerge from within a qemu-chroot (t...
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Anthony Basile
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-19 15:26 UTC by tt_1
Modified: 2020-01-01 11:07 UTC (History)
7 users (show)

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


Attachments
output of emerge --info (emerge-info-host,6.83 KB, text/plain)
2018-09-19 15:26 UTC, tt_1
Details
compressed build.log for musl (musl-build.log.tar.bz2,21.55 KB, application/x-bzip)
2018-09-19 15:31 UTC, tt_1
Details
compressed build.log for glibc (glibc-build-log.tar.bz2,190.81 KB, application/x-bzip)
2018-09-19 18:51 UTC, tt_1
Details
disable_trace.patch (disable_trace.patch,1.63 KB, patch)
2020-01-01 11:04 UTC, Andrew Aladjev
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tt_1 2018-09-19 15:26:18 UTC
Created attachment 547302 [details]
output of emerge --info

affected packages: 

sys-libs/glibc (src_install)
sys-libs/musl (src_install)
(to be continued)

qemu is stable 2.12.1 

dmesg is clean 

actual error (for the case of musl): 

./tools/install.sh -D -m 644 include/values.h /var/tmp/portage/sys-libs/musl-1.1.20/image//usr/include/values.h
./tools/install.sh -D -m 644 include/wait.h /var/tmp/portage/sys-libs/musl-1.1.20/image//usr/include/wait.h
./tools/install.sh -D -m 644 include/wchar.h /var/tmp/portage/sys-libs/musl-1.1.20/image//usr/include/wchar.h
./tools/install.sh -D -m 644 include/wctype.h /var/tmp/portage/sys-libs/musl-1.1.20/image//usr/include/wctype.h
./tools/install.sh -D -m 644 include/wordexp.h /var/tmp/portage/sys-libs/musl-1.1.20/image//usr/include/wordexp.h
./tools/install.sh -D -l /usr/lib/libc.so /var/tmp/portage/sys-libs/musl-1.1.20/image//lib/ld-musl-armhf.so.1 || true
 * /var/tmp/portage/sys-apps/sandbox-2.13/work/sandbox-2.13/libsandbox/trace.c:_do_ptrace():75: failure (Function not implemented):
 * ISE:_do_ptrace: ptrace(PTRACE_TRACEME, ..., 0x00000000, 0x00000000): Function not implemented
 * ERROR: sys-libs/musl-1.1.20::gentoo failed (install phase):
 *   (no error message)
 * 
 * Call stack:
 *     ebuild.sh, line 124:  Called src_install
 *   environment, line 2282:  Called die
 * The specific snippet of code:
 *           [[ -e "${D}"/lib/ld-musl-${arch}.so.1 ]] || die;
 * 
 * If you need support, post the output of `emerge --info '=sys-libs/musl-1.1.20::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-libs/musl-1.1.20::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/sys-libs/musl-1.1.20/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-libs/musl-1.1.20/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-libs/musl-1.1.20/work/musl-1.1.20'
 * S: '/var/tmp/portage/sys-libs/musl-1.1.20/work/musl-1.1.20'
Comment 1 tt_1 2018-09-19 15:28:19 UTC
more details about my qemu installation on the host: 

[ebuild   R    ] app-emulation/qemu-2.12.1::gentoo  USE="aio alsa bzip2 caps curl fdt filecaps gtk jpeg lzo ncurses nls opengl pin-upstream-blobs png sasl sdl seccomp smartcard static-user usb vhost-net vnc xattr -accessibility -bluetooth -capstone -debug -glusterfs -gnutls -gtk2 -infiniband -iscsi -nfs -numa -pulseaudio -python -rbd -sdl2 (-selinux) -snappy -spice -ssh (-static) -systemtap -tci -test -usbredir -vde -virgl -virtfs -vte -xen -xfs" PYTHON_TARGETS="python2_7 python3_6 -python3_4 -python3_5" QEMU_SOFTMMU_TARGETS="arm i386 x86_64 -aarch64 -alpha -cris -hppa -lm32 -m68k -microblaze -microblazeel -mips -mips64 -mips64el -mipsel -moxie -nios2 -or1k -ppc -ppc64 -ppcemb -riscv32 -riscv64 -s390x -sh4 -sh4eb -sparc -sparc64 -tricore -unicore32 -xtensa -xtensaeb" QEMU_USER_TARGETS="aarch64 arm -aarch64_be -alpha -armeb -cris -hppa -i386 -m68k -microblaze -microblazeel -mips -mips64 -mips64el -mipsel -mipsn32 -mipsn32el -nios2 -or1k -ppc -ppc64 -ppc64abi32 -ppc64le -riscv32 -riscv64 -s390x -sh4 -sh4eb -sparc -sparc32plus -sparc64 -tilegx -x86_64 -xtensa -xtensaeb" 0 KiB

which I install via 'cp /usr/bin/qemu-arch $CHROOT/usr/bin/' 

sandbox install on the host is: 

[ebuild   R    ] sys-apps/sandbox-2.13::gentoo  ABI_X86="(32) (64) (-x32)" 0 KiB
Comment 2 tt_1 2018-09-19 15:31:33 UTC
Created attachment 547304 [details]
compressed build.log for musl

I'll attach the one for glibc soon.
Comment 3 tt_1 2018-09-19 18:51:59 UTC
Created attachment 547344 [details]
compressed build.log for glibc

this is the error for glibc: 

qemu: Unsupported syscall: 26
 * /var/tmp/portage/sys-apps/sandbox-2.13/work/sandbox-2.13/libsandbox/trace.c:_do_ptrace():75: failure (Function not implemented):
 * ISE:_do_ptrace: ptrace(PTRACE_TRACEME, ..., 0x00000000, 0x00000000): Function not implemented
/proc/7257/cmdline: /usr/bin/make -r PARALLELMFLAGS= -C /var/tmp/portage/sys-libs/glibc-2.26-r7/work/glibc-2.26 objdir=/var/tmp/portage/sys-libs/glibc-2.26-r7/work/build-arm-armv6j-unknown-linux-gnueabihf-nptl install
Comment 4 tt_1 2018-09-19 18:59:53 UTC
there are likely various other affected packages, for instance gcc or gtk+2: 

 * /var/tmp/portage/sys-apps/sandbox-2.13/work/sandbox-2.13/libsandbox/trace.c:_do_ptrace():75: failure (Function not implemented):
 * ISE:_do_ptrace: ptrace(PTRACE_TRACEME, ..., 0x00000000, 0x00000000): Function not implemented

but in the case of gcc or gtk+2 it doesn't make the build fail (this makes them harder to catch as well)

so the two libc's are the most important ones

now, can I use 'armv6j-unknown-linux-gnueabihf-emerge' (cross-emerge) to emerge glibc this way and install it later from within the CHROOT? cross-emerge does have FEATURES="buildpkg" activated by default, so that makes me think it is possible to copy over the package folder to the chroot and do an emerge --oneshot -av -K from within the armv6j-chroot.
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2018-09-19 20:08:24 UTC
The bug (or rather a missing features) is in qemu-arm (user emulation) that does not support ptrace() syscall.

To work it around you can try to disable sandbox with FEATURES="-sandbox -usersandbox".

The bug is not specific to package being built.
Comment 6 tt_1 2018-09-19 20:52:33 UTC
I'll try to disable sandboxing and be back with the results. 

If not, does the approach of using cross-emerge + binpkg give me a valid glibc? Or musl, for the sake of the argument?
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2018-09-21 06:25:14 UTC
(In reply to tt_1 from comment #6)
> I'll try to disable sandboxing and be back with the results. 
> 
> If not, does the approach of using cross-emerge + binpkg give me a valid
> glibc? Or musl, for the sake of the argument?

Both binpkgs should work. If they don't it's a bug and should be reported/fixed.
Comment 8 tt_1 2018-09-24 09:24:37 UTC
FEATURES="-sandbox -usersandbox" allows to compile musl through qemu-static for the case of arm. Are there any negative side effects about disabling the sandbox? 

Also affected by the breakage is >=firefox-60.x,  where the segfault occurs when testing for rust/cargo during src_configure. I may try to disable sandboxing for testing.
Comment 9 Sergei Trofimovich (RETIRED) gentoo-dev 2018-09-24 19:02:21 UTC
(In reply to tt_1 from comment #8)
> FEATURES="-sandbox -usersandbox" allows to compile musl through qemu-static
> for the case of arm. Are there any negative side effects about disabling the
> sandbox? 

Less resilience against bugs in ebuild or package that can wipe your system out. Sandbox tries to make sure there are no mutating accesses outside the sandbox.

In practice it should not matter much for ebuilds in ::gentoo.

> Also affected by the breakage is >=firefox-60.x,  where the segfault occurs
> when testing for rust/cargo during src_configure. I may try to disable
> sandboxing for testing.

This might be different: bug #663690
Comment 10 Alexey Shvetsov archtester gentoo-dev 2018-11-10 16:21:30 UTC
I have same bug with qemu-user-arm + lxc (trying to build packages with that).

Seems like qemu dont have ptrace() syscall
Comment 11 tt_1 2018-11-11 10:20:49 UTC
Would it be worth trying to use qemu-static built from within a musl env?
Comment 12 tt_1 2019-01-19 12:54:23 UTC
Should this bug be closed as can't fix, in favour of doing a real cross compile with cross-emerge? It seems to work just fine for glibc.
Comment 13 tt_1 2019-03-03 15:03:49 UTC
qemu doesn't have the syscall, and it's close to impossible that it will ever be implemented. Therefore closing as cantfix. A cross-compile of binutils, gcc and glibc or musl is possible with cross-emerge wrappers.
Comment 14 Andrew Aladjev 2019-12-29 14:13:30 UTC
Hello. Qemu user has no support for ptrace and it is fine. Sandbox library has a special flag "SB_NO_TRACE". I think this issue means that this flag detection mechanism can to be improved.

Personally I don't like autoconf, not using it, so I can't provide a proper patch for ptrace detection. But the method is very simple:

1. If we are doing cross compilation - "define SB_NO_TRACE".
2. Check that we can run compiled binary.
3. If we can't run binary - ptrace support is unknown, "define SB_NO_TRACE".
4. If we can't compile test file - "define SB_NO_TRACE".
5. If we've failed running test binary - "define SB_NO_TRACE".
6. "undef SB_NO_TRACE"

If we are doing a cross compilation - we can use a quick patch that just replaces current ptrace detection mechanism with "define SB_NO_TRACE".
Comment 15 Sergei Trofimovich (RETIRED) gentoo-dev 2019-12-29 14:55:06 UTC
(In reply to Andrew Aladjev from comment #14)
> Hello. Qemu user has no support for ptrace and it is fine. Sandbox library
> has a special flag "SB_NO_TRACE". I think this issue means that this flag
> detection mechanism can to be improved.
> 
> Personally I don't like autoconf, not using it, so I can't provide a proper
> patch for ptrace detection. But the method is very simple:
> 
> 1. If we are doing cross compilation - "define SB_NO_TRACE".
> 2. Check that we can run compiled binary.
> 3. If we can't run binary - ptrace support is unknown, "define SB_NO_TRACE".
> 4. If we can't compile test file - "define SB_NO_TRACE".
> 5. If we've failed running test binary - "define SB_NO_TRACE".
> 6. "undef SB_NO_TRACE"
> 
> If we are doing a cross compilation - we can use a quick patch that just
> replaces current ptrace detection mechanism with "define SB_NO_TRACE".

Detection has to happen at runtime. It's fine to cross-compile sandbox and expect it to run on target system. https://bugs.gentoo.org/693582 should cover the case once fixed.
Comment 16 Andrew Aladjev 2019-12-29 14:57:57 UTC
Yes, runtime detection will be much better, thank you.
Comment 17 Andrew Aladjev 2020-01-01 11:04:57 UTC
Created attachment 602156 [details, diff]
disable_trace.patch
Comment 18 Andrew Aladjev 2020-01-01 11:07:26 UTC
I've added a small workaround for now. You can just put it into "/usr/arm-unknown-linux-gnueabi/etc/portage/patches/sys-apps/sandbox/disable_trace.patch" and it will work perfect.