rizsotto / scan-build

Clang's scan-build re-implementation in python
Other
362 stars 34 forks source link

ERROR: ld.so: object '/tmp/intercept-Qjyz5c/libear.so' from LD_PRELOAD cannot be preloaded: ignored. #113

Closed aashish29n closed 5 years ago

aashish29n commented 5 years ago

Hi i am getting this issue when i am running scan-build-py on a host with intercept-first option. This is my environment variable value:- LC_CTYPE': 'UTF-8', 'SSH_CLIENT': '172.29.178.91 55742 22', 'INTERCEPT_BUILD_TARGET_DIR': '/tmp/intercept-Qjyz5c', 'LOGNAME': 'aashisha', 'USER': 'aashisha', 'PATH': '/volume/evo/files/share/buildtools/sandbox-tools/bin:/volume/buildtools/bin/:/volume/coverity/jnpr/Linux/Ubuntu-12.04/x86_64/python/2.7.12/bin:/volume/buildtools/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/homes/aashisha/bin', 'HOME': '/homes/aashisha', 'LANG': 'en_US.UTF-8', 'TERM': 'screen', 'SHELL': '/bin/bash', 'XDG_SESSION_COOKIE': 'd8d4dc964773c6c6e0e0d674000005e6-1556692912.435831-368175968', 'NEED_CLEAN_ENV': 'no', 'BLOCKSIZE': 'K', 'PWD': '/b/aashisha/DCBnew/src', 'EDITOR': 'vi', 'ENV': '/homes/aashisha/.shrc', 'STY': '3906.pts-2.contrail-ubm-aashisha', '': '/usr/bin/python', 'LD_PRELOAD': '/tmp/intercept-Qjyz5c/libear.so', 'TERMCAP': 'SC|screen|VT 100/ANSI X3.64 virtual terminal:\\n\t:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:\\n\t:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\\n\t:do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\\n\t:le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\\n\t:li#44:co#100:am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SSH_CONNECTION': '172.29.178.91 55742 10.224.49.177 22', 'PAGER': 'more'

os:- UNIX Needed your help in this issue

rizsotto commented 5 years ago

Hey @aashish29n , thanks for the report. I need more context in order to help. What OS do you use? (UNIX is not an OS name. I need the name and version.) How did you installed this program?

aashish29n commented 5 years ago

Hi rizsotto, i just downloaded this python script from git and i run this script with this command:- python path to scan-build-py/bin/scan-build --intercept-first --use-analyzer=path to clang -vvv -o=/b/aashisha/clangreports /volume/buildtools/bin/mk -j20 | tee console.log OS:- Ubuntu VERSION="12.04.4 LTS, Precise Pangolin" i want to do host build on my sandbox and i have to generate reports but while doing that lot of files are failing and i am guessing those are failing because of the above error.

rizsotto commented 5 years ago

Thanks to come back. Please try to install it as recommended in the readme. (You can use virtualenv that helps to isolate from other things on your machine.)

aashish29n commented 5 years ago

readme says that i only need a python interpreter.

rizsotto commented 5 years ago

That's true. If you can install this python package, then it will work with a python interpreter.

I want to help you here. And just want to make sure, that the problem of yours is not caused by installation. That's why I do recommend to install it from pip... And because I don't know whether you have root access to this machine or not. I do recommend to use virtualenv, because that can be used without privilages.

If you are sure that the installation works, then let's find out why the LD_PRELOAD fails for the linker. This error message usually appears if the file is not exists. So, we need to check if it is there... You will need to search in the log for entries which tells, where the shared object was put. (Or check for error messages.) The scan-build program compiles a C program into a shared library before do run your build command. It puts the shared library into a temporary directory and deletes it before it quits. (That's why you can't just check with ls command.)

aashish29n commented 5 years ago

Hi my installation is working fine.And i have checked in my console log that it is creating that libear.so file in a /tmp/intercept-"name" directory. i have also checked that with a python debugger that after the build command that /tmp/intercept-"name" directory contains all the .cmd files and libear.so file.

rizsotto commented 5 years ago

Ok, sounds good then... Can you help me out, what are the .cmd files? (Was a long time I've wrote this program, but can't recall any file extensions like that.)

aashish29n commented 5 years ago

those .cmd files contains info like these:- 0608^^30602^^execve^^/b/aashisha/DCB3/obj/common/junos/usr.sbin/alarmd/odl/alarmd/gen^^mkdir^-p^/b/aashisha/DCB3/obj/stage/common/usr/lib/render^_^] which is pid,ppid,function name,directory name and command scan build parse this .cmd files and take command from these .cmd files

rizsotto commented 5 years ago

Understand now, thanks! I did not remember for them, because it was long before it was doing that. Looks like you are using some old version of the tool. Can you update it to the latest? (2.0.15)

aashish29n commented 5 years ago

can you help me find out my tools version pls??

rizsotto commented 5 years ago

If you were clone the git repo, you can check git tag. If you were install from pip, pip list will tell you.

aashish29n commented 5 years ago

hi i have checked that 2.0.15 version. In that couldn't find bin folder. So without that bin which script should i invoke . url of latest version:- https://pypi.org/project/scan-build/#files will this url works

aashish29n commented 5 years ago

And i still didn't got why the version i am using giving that error?

rizsotto commented 5 years ago

Yes, the 2.0.15 does not have the bin directory. (It needs to be installed as a package.)

I don't know why that version (you got) does not work... But prefer to help you with the latest, because if there is a bug, we can make a bugfix for that easy. And because you don't know which version you are using, that's hard to reproduce on my end.

aashish29n commented 5 years ago

Can i take the bin folder of my previous version of scan-build-py and place in that latest versions folder. :) :) This is the location from where i am using scanbuild from this url:- https://psd-tools-git01.juniper.net/tools-tot/clang/tree/jnpr-release_70/tools/scan-build-py and i am using clang 5.0 as my analyzer. By the way Does it maintain separate version ? i thought its same as clang. i downloaded the latest version and i will try that latest version just that i don't know how to install that bin folder as a package

when i tried git tag from my scan-build-py location it gave me this output:- 20151118 20151123 20160416 20161010 20161124 20170315 20170630 20170925 20171023 20180301 20180524 20180613 20180816 20190128 20190222 20190306 20190405

can you help pls

rizsotto commented 5 years ago

Ok, it looks like you don't use this tool, but the one from the Clang repo. :)

So, if you want to fix your current scan-build, ask the Clang mailing list... If you want to work with this tool, I would recommend (again) to install it from pip. (I don't understand the hesitation to use virtualenv and install with pip. Even older ubuntu will do it without problem.)

aashish29n commented 5 years ago

sure i will install it with pip on a virtual environment

aashish29n commented 5 years ago

Hi really sorry for delay. Actually my main problem is that my scan-build is not picking up the right compiler in the analysis phase. i have generated the compilation database. In that compilation database i have proper compiler name but when i run the analyze-build on that compilation database i am getting script failure because i have lot gcc file which fails because it try to build those files with clang only. so for gcc files it gives error like some gcc flags are not supported. So is their any way so that i can specify --use-cc value in the script for each file. pls respond really need your help in this.

rizsotto commented 5 years ago

Hi @aashish29n , so you solved your original problem? If yes, I would close this ticket.

The --use--analyzer flag can specify which Clang to run. If you run the analyze-build command with verbose flags -vvvv then you will see if it executes it correctly or not. If Clang does not understand some flag, you can remove it from the compilation database. Or create a new ticket, and propose that to filter out durring the analyse phase.

aashish29n commented 5 years ago

Yes i have resolved my original problem. You can close this ticket. Really Thanks for your help. i will create a new ticket for this matters.