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

build-wrapper
cpp
sonarqube

(Stefan) #1

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.


(Evgeny Mandrikov) #2

There was a regression in glibc library version 2.26 - https://sourceware.org/bugzilla/show_bug.cgi?id=22299 , 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 https://packages.ubuntu.com/search?keywords=libc-bin => artful-updates ( https://packages.ubuntu.com/artful-updates/libc-bin ) => 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 https://packages.ubuntu.com/search?keywords=libc-bin => bionic ( https://packages.ubuntu.com/bionic/libc-bin ). 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 https://wiki.ubuntu.com/Releases , 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)

(Stefan) #3

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.


(Stefan) #4

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

(Arnaud Gelas) #5

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?


(Evgeny Mandrikov) #6

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

(Stefan) #7

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)


ERROR: ld.so: object
Sonarqube-developer-7.4: build-wrapper exits unexpecedly with build-wrapper: SQ_WRAPPER_SOCKET is missing
(Evgeny Mandrikov) #8

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

?


Sonarqube-developer-7.4: build-wrapper exits unexpecedly with build-wrapper: SQ_WRAPPER_SOCKET is missing
ERROR: ld.so: object
(Stefan) #9

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


(Evgeny Mandrikov) #10

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


(Roman Lebedev) #11

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