SonarQube - C++ - Ubuntu - build-wrapper LD_PRELOAD Error

SonarQube Version 7.1 build 11001

Reproduce:

docker run -it ubuntu:18.04 bash
apt-get update
apt-get install wget unzip
wget 192.168.1.5:9000/static/cpp/build-wrapper-linux-x86.zip
unzip build-wrapper-linux-x86.zip
cd build-wrapper-linux-x86
./build-wrapper-linux-x86-64 --out-dir test ls

ERROR: ld.so: object '/build-wrapper-linux-x86/libinterceptor-${PLATFORM}.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

Docker images 16.04, 16.10 are working, 17.10, 18.04 are not working. It seems like the build-wrapper is incompatible with the new ubuntu versions.

1 Like

There was a regression in glibc library version 2.26 - 22299 – Problem with $PLATFORM on x86_64 platform , which unfortunately affects build-wrapper. From the above ticket regression was fixed in version 2.27.

Unfortunately Ubuntu 17.10 comes with glibc version 2.26 and without patch for the above problem - see Ubuntu – Package Search Results -- libc-bin => artful-updates ( Ubuntu – Error ) => Ubuntu Changelog ( http://changelogs.ubuntu.com/changelogs/pool/main/g/glibc/glibc_2.26-0ubuntu2.1/changelog ).

Ubuntu 18.04 comes with glibc version 2.27 with fix for the above problem - see Ubuntu – Package Search Results -- libc-bin => bionic ( Ubuntu – Error ). And build-wrapper perfectly works on it:

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              18.04               113a43faa138        13 days ago         81.1MB

$ docker run -it --rm ubuntu:18.04 env PS1='(ubuntu:18.04) $ ' sh
(ubuntu:18.04) $ apt-get -qq update
(ubuntu:18.04) $ apt-get -qq -y install wget unzip
(ubuntu:18.04) $ wget -q https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
(ubuntu:18.04) $ unzip -q build-wrapper-linux-x86.zip
(ubuntu:18.04) $ ./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir test /bin/echo test
test

So I think that your test of Ubuntu 18.04 was flawed.

Should be noted that Ubuntu 17 is not an LTS version and will reach EOL in July 2018 - see Releases - Ubuntu Wiki , and we are not planning to try find a workaround on our side for it.

Also please keep in mind that not always possible to implement workarounds for bugs in third-party components, especially when they are at a such low level - loader of executable files.

P.S.

SonarQube Version 7.1 build 11001

build-wrapper is part of SonarCFamily Plugin and there is no way to guess their versions from version of SonarQube server. build-wrapper prints its version when executed without parameters:

$ ./build-wrapper-linux-x86/build-wrapper-linux-x86-64
build-wrapper, version 5.1 (linux-x86)
1 Like

Thanks for your reply, but the problem definitely exists also with ubuntu 18.04. Cleanely pulled the image on 3 computers, on all of them i got the same problem. Even exactly following your steps. Maybe the problem is the host system? Host is Ubuntu 17.10.

Confirm, it works on 16.04 Host system with 18.04 docker container.
Still have the problem on 17.10 and 18.04 host systems with 17.10 or 18.04 docker.
Also still have the same problem on a native ubuntu 18.04 without docker.

Host/Docker 16.10 17.10 18.04
16.04 works works
17.10 works x x
18.04 works x x

I have exactly the same problem on Ubuntu 18.04 (LTS).

ERROR: ld.so: object '/home/agelas/Downloads/sonar/build-wrapper-linux-x86/libinterceptor-${PLATFORM}.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

Here is my configuration:

$ apt-cache policy libc-bin
libc-bin:
  Installed: 2.27-3ubuntu1
  Candidate: 2.27-3ubuntu1
  Version table:
 *** 2.27-3ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status


$ build-wrapper-linux-x86-64 
build-wrapper, version 5.1 (linux-x86)
Copyright (C) 2014-2017 SonarSource SA, info@sonarsource.com

Any idea?

I just downloaded and installed Ubuntu 18.04 from https://www.ubuntu.com/download/desktop and build-wrapper works on it:

And in Docker on it:

Furthermore, despite the fact that I strongly believe that we should stop discussing non-LTS-soon-end-of-life version, I downloaded and installed Ubuntu 17.10.1 from http://releases.ubuntu.com/17.10/ and as already explained above - build-wrapper doesn’t work on it. However works in Docker on Ubuntu 17.10.1, what seems quite logical to me - AFAIK Docker container uses host’s kernel, but not loader of executables:

Thus I truly have no idea how we can reproduce your problem. Can you provide exact steps to follow?
And please provide all the output of a tracing of a failing execution as following (directory bw-output and files stdout.txt and stderr.txt):

strace -f -E LD_DEBUG=all ./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output /bin/echo test >stdout.txt 2>stderr.txt
1 Like

Strange thing, i did exactly the same, downloaded fresh ubuntu 18.04 from their homepage, plain install, error occures. The only thing i do during install is setting the language to german.

Your requested logs from an Ubuntu 18.04 docker running on a 18.04 host.

stdout.txt (5 Bytes)
stderr.txt (740.7 KB)

And directly executed on the host native ubuntu 18.04 (no docker)

1 Like

I also asked directory bw-output, but never mind - here is important traces of a problem from provided logs:

[pid 32712] openat(AT_FDCWD, "/home/jenkins/build-wrapper-linux-x86/libinterceptor-haswell.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

Clearly your host architecture is different from mine.

While still should be investigated why previous version of loader of executables works differently on the same host, could you please try following possible workaround:

either copy libinterceptor-x86_64.so into libinterceptor-haswell.so

cp ./build-wrapper-linux-x86/libinterceptor-x86_64.so ./build-wrapper-linux-x86/libinterceptor-haswell.so

(make sure to not remove original file)

or create symlink libinterceptor-haswell.so to libinterceptor-x86_64.so

ln -s libinterceptor-x86_64.so ./build-wrapper-linux-x86/libinterceptor-haswell.so

?

6 Likes

Great, copying the lib works perfectly! Thank you! :grinning::+1:

Thank you, Stefan, for helping us to uncover this and confirmation that workaround works :thumbsup: :heart:

Here is a ticket to track future progress on replacement of this workaround with something better - https://jira.sonarsource.com/browse/CPP-2027

2 Likes

FYI debian testing-based docker image + travis-ci with

    dist: trusty	
    sudo: required

appear to also be affected, even though debian testing has libc 2.27.

Changing travis config (as suggested by Travis support) workarounds this:

    sudo: required
    dist: xenial
    edge: true
1 Like

issue still exists on
Ubuntu 19.04
libc 2.29

Hi @demoth,

thank you for sharing that.

Same issue here with Travis CI and Ubuntu 18.04.

strace -f -E LD_DEBUG=all build-wrapper-linux-x86-64 --out-dir bw-output make

[pid  6310] getpid()                    = 6310
[pid  6310] writev(2, [{iov_base="      6310:\t", iov_len=12}, {iov_base="\n", iov_len=1}, {iov_base="      6310:\t", iov_len=12}, {iov_base="file=", iov_len=5}, {iov_base="/home/travis/.sonar/cache/87f753"..., iov_len=112}, {iov_base=" [", iov_len=2}, {iov_base="0", iov_len=1}, {iov_base="];  needed by ", iov_len=14}, {iov_base="build-wrapper-linux-x86-64", iov_len=26}, {iov_base=" [", iov_len=2}, {iov_base="0", iov_len=1}, {iov_base="]\n", iov_len=2}], 12      6310:	6310:	file=/home/travis/.sonar/cache/87f7532f0609a32b83c77be7ae487f14/build-wrapper-linux-x86/libinterceptor-${PLATFORM}.so [0];  needed by build-wrapper-linux-x86-64 [0]) = 190
[pid  6310] readlink("/proc/self/exe", "/home/travis/.sonar/cache/87f753"..., 4096) = 109
[pid  6310] openat(AT_FDCWD, "/home/travis/.sonar/cache/87f7532f0609a32b83c77be7ae487f14/build-wrapper-linux-x86/libinterceptor-haswell.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  6310] writev(2, [{iov_base="ERROR: ld.so: object '", iov_len=22}, {iov_base="/home/travis/.sonar/cache/87f753"..., iov_len=112}, {iov_base="' from ", iov_len=7}, {iov_base="LD_PRELOAD", iov_len=10}, {iov_base=" cannot be preloaded (", iov_len=22}, {iov_base="cannot open shared object file", iov_len=30}, {iov_base="): ignored.\n", iov_len=12}], 7ERROR: ld.so: object '/home/travis/.sonar/cache/87f7532f0609a32b83c77be7ae487f14/build-wrapper-linux-x86/libinterceptor-${PLATFORM}.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.) = 215
[pid  6310] access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)

Fixed with hackround in .travis.yml

script:
    - INTERCEPTOR_LIB=`find ${TRAVIS_HOME} -name libinterceptor-x86_64.so`
    - INTERCEPTOR_LINK=`sed "s/x86_64/haswell/g"<<<"$INTERCEPTOR_LIB"`
    - ln -s $INTERCEPTOR_LIB $INTERCEPTOR_LINK

Issue still present Ubuntu 20.04 on 2020/10/16.

Hi @FrancoisCarouge,

your message is kind of useless without additional information. The issue has been fixed in version 6.7 of the CFamily analyzer: [CPP-2027] - Jira. If you are facing an issue please open a new topic providing some information