Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/usr/bin/ld: cannot find /usr/lib64/libasan.so.0.0.0 on redhat

I am normally using valgrind for my c/c++ programs but people have been recommending address sanitizer, so I wanted to test it out, but im having problems linking against it on a redhat system.

I got the following code:

$ cat heap-use-after-free.cpp

int main(int argc, char **argv) {
  int *array = new int[100];
  delete [] array;
  return array[argc];  // BOOM
}

compiling like:

$ g++ -O -g -fsanitize=address heap-use-after-free.cpp

/usr/bin/ld: cannot find /usr/lib64/libasan.so.0.0.0
collect2: error: ld returned 1 exit status

On a redhat where I have installed libasan

sudo yum install libasan
[sudo] password for dingdongsong: 
Loaded plugins: langpacks, product-id, rhnplugin, search-disabled-repos, subscription-manager
This system is receiving updates from RHN Classic or Red Hat Satellite.
rh-network-tools-rhel-x86_64-server-7-prod                                                                                                                                                                                                           | 1.5 kB  00:00:00     
rhel-x86_64-server-7-custom-prod                                                                                                                                                                                                                     | 1.0 kB  00:00:00     
rhel-x86_64-server-7-epel-prod                                                                                                                                                                                                                       | 1.5 kB  00:00:00     
rhel-x86_64-server-7-prod                                                                                                                                                                                                                            | 1.5 kB  00:00:00     
rhel-x86_64-server-7-rhscl-1-prod                                                                                                                                                                                                                    | 1.5 kB  00:00:00     
rhel-x86_64-server-7-thirdparty-oracle-java-prod                                                                                                                                                                                                     | 1.5 kB  00:00:00     
rhel-x86_64-server-extras-7-prod                                                                                                                                                                                                                     | 1.5 kB  00:00:00     
rhel-x86_64-server-optional-7-prod                                                                                                                                                                                                                   | 1.5 kB  00:00:00     
rhel-x86_64-server-supplementary-7-prod                                                                                                                                                                                                              | 1.5 kB  00:00:00     
Package libasan-4.9.2-6.2.el7.x86_64 already installed and latest version
Nothing to do

With the following libasan shared objects:

$ locate libasan

/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/32/libasan.a
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/32/libasan.so
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/32/libasan_preinit.o
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libasan.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libasan_preinit.o
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libasan.a
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libasan.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libasan_preinit.o
/usr/lib64/libasan.so.1
/usr/lib64/libasan.so.1.0.0

Can someone point me in the right direction.

Thanks

like image 684
monkeyking Avatar asked Jun 18 '19 15:06

monkeyking


1 Answers

It looks like it's looking for an earlier version of the library than you have. Try doing this and see what it says:

sudo yum install /usr/lib64/libasan.so.0.0.0

Also, are you sure that your version of the gcc-c++ package is up-to-date?

The version of the libasan package I have in a CentOS 7 container that works is this: libasan-4.8.5-36.el7_6.2.x86_64.

like image 176
Omnifarious Avatar answered Sep 30 '22 07:09

Omnifarious