5

I am trying to use AddressSanitizer on Raspbian.

I use the following to compile my program:

gcc -fsanitize=address -fno-omit-frame-pointer -g prog.c -o prog

Even for the simplest program (just a Hello World), I get the following when trying to run it:

==1966==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.

While I can work around this using the -static-libasan compilation flag, I would like to understand why this happens on Raspbian, but not on other platforms. I do not see the same on x86_64 Ubuntu 16.04 or 19.04.

What exactly is different in Raspbian that causes this?

I was hoping to be able to compile and run programs in a uniform way on multiple platforms (including x86_64 Linux and macOS, even in debug mode with AddressSanitizer). Some platforms may require special flags, but I would like to understand how to correctly detect that.

Szabolcs
  • 662
  • 2
  • 6
  • 18

1 Answers1

2

Basically libasan can not guarantee correct work if it's not the first loaded library (which is e.g. the case when /etc/ld.so.preload is not empty). There were several cases when preloaded libraries caused Asan misbehaviors and this check -- ==1966==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD. was added to prevent them.

user96931
  • 739
  • 2
  • 9
  • 22