Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use address sanitizer in a program that links against compute-runtime #376

Closed
Bidski opened this issue Nov 9, 2020 · 5 comments

Comments

@Bidski
Copy link

Bidski commented Nov 9, 2020

I am running an application that links against the compute-runtime that I am trying to run an address sanitizer on. At runtime I get the following error

You are trying to dlopen a libigfxdbgxchg64.so shared library with RTLD_DEEPBIND flag which is incompatibe with sanitizer runtime (see https://github.com/google/sanitizers/issues/611 for details). If you want to run libigfxdbgxchg64.so library under sanitizers please remove RTLD_DEEPBIND from dlopen flags.  

I noticed in https://github.com/intel/compute-runtime/blob/master/shared/source/os_interface/linux/os_library_linux.cpp#L37-L42 that you are checking for a SANITIZER_BUILD compile definition and disabling RTLD_DEEPBIND if it is defined. However, this only works if the compute-runtime was compiled with this flag defined. Is it possible to move this check into a header file so that when people wish to use address sanitizers in their applications they don't need to recompile the compute-runtime as well?

@Bidski Bidski closed this as completed Nov 9, 2020
@Bidski Bidski reopened this Nov 16, 2020
@Bidski
Copy link
Author

Bidski commented Nov 16, 2020

With further investigation I have found that this is still broken in a strange way.

When running cmake with -DUSE_ASAN=ON to build the compute runtime any program that either links against or loads (via libOpenCL.so) the compute runtime must either link against libasan.so itself or must have libasan.so preloaded for it (using LD_PRELOAD environment variable). This includes programs like clinfo which will fail to detect the Intel GPU platform if libasan.so is not preloaded for it.

This behaviour is different from the behaviour of every other library that I am working with. With all other libraries I am able to enable address sanitization in my own program without needing to recompile any of the other libraries.

Is there some way to either remove RTLD_DEEPBIND from the compute runtime? The only options I can immediately think of that would allow RTLD_DEEPBIND to be used in the compute runtime library is either an environment variable or a configuration file.

If we consider the scenario of someone linking against the compute runtime library that they obtained from a prebuilt deb package (like the ones provided on the github releases page) and they try to run the address sanitizer on their own code they will meet the error that I received in my original post. The only way they will be able to do this is to download and compile the compute runtime and all of its dependencies from source, which they shouldn't ever have to do.

@HoppeMateusz
Copy link
Contributor

Hello,

Issue with DEEPBIND should be resolved by: 66f4c75

In order to disable passing DEEPBIND flag to dlopen() in NEO, you need to set two environment variables:
NEOReadDebugKeys=1 DisableDeepBind=1

Please let us know if such configuration resolves the issue.

Mateusz

pascalj added a commit to pascalj/resch that referenced this issue Feb 23, 2023
One must set both environment variables `NEOReadDebugKeys=1 DisableDeepBind=1`, since compute-runtime on Intel loads shared objects with `RTLD_DEEPBIND`. That breaks asan.

See intel/compute-runtime#376
@kallaballa
Copy link

It works,. I can run now tsan (and other sanitizers!).

@MajidAbdelilah
Copy link

it doesnt work for me NEOReadDebugKeys=1 DisableDeepBind=1 doesnt work for me

@MajidAbdelilah
Copy link

export NEOReadDebugKeys=1
export DisableDeepBind=1
dpcpp host_vs_device_code.cpp -g -fsanitize=thread
./a.out
==6411==You are trying to dlopen a libur_adapter_level_zero.so.0 shared library with RTLD_DEEPBIND flag which is incompatible with sanitizer runtime (see https://github.com/google/sanitizers/issues/611 for details). If you want to run libur_adapter_level_zero.so.0 library under sanitizers please remove RTLD_DEEPBIND from dlopen flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants