Bug 9761 - Failed to extract rootfs by using runqemu-extract-sdk
Summary: Failed to extract rootfs by using runqemu-extract-sdk
Status: VERIFIED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: Scripts and Tools (show other bugs)
Version: 2.2
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 2.2 M1
Assignee: Ed Bartosh
QA Contact: Yi Zhao
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-06-13 07:04 UTC by Yi Zhao
Modified: 2016-08-03 02:04 UTC (History)
7 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: Regression (Used to work)
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yi Zhao 2016-06-13 07:04:23 UTC
Git rev: master/6c5d7f1fb276cbe0a461ece6c8f0ca17a478fa8c
Image location: https://autobuilder.yoctoproject.org/pub/nightly/20160605-1/

Steps:
1. Download kernel, rootfs tarball and toolchain from https://autobuilder.yoctoproject.org/pub/nightly/20160605-1/

2. Install toolchain and set the environment:

$ ./poky-glibc-x86_64-core-image-sato-armv5e-toolchain-2.1+snapshot.sh 
Poky (Yocto Project Reference Distro) SDK installer version 2.1+snapshot
========================================================================
Enter target directory for SDK (default: /opt/poky/2.1+snapshot): 
You are about to install the SDK to "/opt/poky/2.1+snapshot". Proceed[Y/n]? 
Extracting SDK.........................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /opt/poky/2.1+snapshot/environment-setup-armv5e-poky-linux-gnueabi
$ . /opt/poky/2.1+snapshot/environment-setup-armv5e-poky-linux-gnueabi
$ which runqemu-extract-sdk 
/opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/runqemu-extract-sdk

3.  Extract the rootfs tarball:

$ runqemu-extract-sdk core-image-sato-sdk-qemuarm-20160605225219.rootfs.tar.bz2 rootfs
Creating directory /home/build/rootfs
Extracting rootfs tarball using pseudo...
/opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/pseudo -P /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr tar -C "/home/build/rootfs" --numeric-owner -xjf "core-image-sato-sdk-qemuarm-20160605225219.rootfs.tar.bz2"
tar: relocation error: /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/lib/pseudo/lib64/../../../../lib/libpthread.so.0: symbol __libc_vfork, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
Warning: I don't see many files in /home/build/rootfs
Please double-check the extraction worked as intended

This issue happens on all hosts ( Ubuntu 14.04 x86_64, openSUSE x86_64 and Debian 8 i686)
Comment 1 Ed Bartosh 2016-06-16 14:01:21 UTC
my findings so far:

1. It can be easily reproduced by running pseudo:
$ /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/pseudo -P /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr
/bin/bash: relocation error: /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/lib/pseudo/lib64/../../../../lib/libpthread.so.0: symbol __libc_vfork, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

2. __libc_vfork exists in libc from the toolchain:
$ objdump -T /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/lib/pseudo/lib64/../../../../lib/libc.so.6 | grep __libc_vfork
00000000000b7a70 g    DF .text  000000000000004b  GLIBC_PRIVATE __libc_vfork

3. __libc_vfork doesn't exist in the host libc:
$ objdump -T /lib64/libc.so.6 | grep __libc_vfork
Comment 2 Ed Bartosh 2016-06-16 15:10:46 UTC
There is a mismatch in linux loader versions:

$ ldd /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/pseudo
        linux-vdso.so.1 (0x00007ffd6aff8000)
        libpthread.so.0 => /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/../../lib/libpthread.so.0 (0x00007f9804fe7000)
        libdl.so.2 => /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/../../lib/libdl.so.2 (0x00007f9804de2000)
        libc.so.6 => /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/../../lib/libc.so.6 (0x00007f9804a40000)
        /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f9805206000)

$ readlink /opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2
ld-2.23.90.so

$ readlink /lib64/ld-linux-x86-64.so.2
ld-2.19.so

What i don't understand is why toolchain loader refers to the host one:
/opt/poky/2.1+snapshot/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f9805206000)
Comment 3 Richard Purdie 2016-06-17 14:02:45 UTC
The problem here is there are two libc versions involved, the one in the SDK which is newer and the host system libc which is older. When you run something like "pseudo bash", its loading both versions of libc and they have conflicting symbols, for example vfork() is an IFUNC in recent libc. This is where the mismatched syymbols come from. Ed found the problem was introduced by:

https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=01cbd46ac5b215bd8b8b1378881ef0bdf61ba177

which adds LDFLAGS. These include rpath entries in the nativesdk case. If we run "chrpath -d libpseudo.so" and remove the RPATH entry things then work as expected since it no longer finds two different libcs.

This is likely the best solution for now. The rpath entries are old and may not be needed with our modern libc/libdl approach so we could look at removing them as a future optimisation in M2.
Comment 4 Richard Purdie 2016-06-17 14:05:43 UTC
Adding seebs so he's at least aware of the issues you can run into with pseudo here.
Comment 5 Ed Bartosh 2016-06-17 15:19:51 UTC
Sent patch for review: http://lists.openembedded.org/pipermail/openembedded-core/2016-June/122971.html
Comment 6 Ed Bartosh 2016-06-20 08:50:50 UTC
The fix has been merged into poky master: https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=8f7f8f7cfa80dc2e1af721388946a28cfdaca1dc
Comment 7 Yi Zhao 2016-08-03 02:04:07 UTC
Verified with 2.2 M2 rc1 build
git rev: master/36feb38045b7a2af86ece147fec54b0db3bf491f