Also, try "-fsanitize=address -shared-libasan", instead of passing "-lasan"
manually.

On Tue, May 26, 2015 at 3:39 PM, 'Evgeniy Stepanov' via address-sanitizer <
[email protected]> wrote:

> Looks like your clang installation is broken. /usr/local/bin/clang is
> 3.6.1, but the libraries in /usr/local/lib/clang are for 3.7.0.
>
>
> On Tue, May 26, 2015 at 3:37 PM, Dmitriy - <[email protected]> wrote:
> > clang++ -fsanitize=address -shared -Wl,--no-undefined -o libshared.so -g3
> > shared.oshared.o: In function `Foo':
> > .../shared.cpp:4: undefined reference to
> > `__asan_option_detect_stack_use_after_return'
> > .../shared.cpp:4: undefined reference to `__asan_stack_malloc_1'
> > .../shared.cpp:4: undefined reference to `__asan_report_store8'
> > .../shared.cpp:4: undefined reference to `__asan_report_load8'
> > .../shared.cpp:6: undefined reference to `__asan_report_store4'
> >
> > If
> > $ clang++ -fsanitize=address -shared -o libshared.so -g3 shared.o -lasan
> >
> > this OK
> > But this commands still don't pass
> >
> > $ clang++ -fno-omit-frame-pointer -fsanitize=address -lshared -L . -g3
> > main.cpp
> > /usr/bin/ld: cannot find
> > /usr/local/bin/../lib/clang/3.6.1/lib/linux/libclang_rt.asan-x86_64.a: No
> > such file or directory
> > /usr/bin/ld: cannot find
> >
> /usr/local/bin/../lib/clang/3.6.1/lib/linux/libclang_rt.asan_cxx-x86_64.a:
> > No such file or directory
> > clang-3.6: error: linker command failed with exit code 1 (use -v to see
> > invocation)
> >
> > output with -v option here - http://pastebin.com/R6ELQPZW
> >
> > I replaced the version on stable 3.6.
> >
> >
> > On Tuesday, May 26, 2015 at 11:35:47 PM UTC+6, Evgeniy Stepanov wrote:
> >>
> >> On Tue, May 26, 2015 at 3:04 AM, Dmitriy - <[email protected]> wrote:
> >> > Hi all.
> >> > Inspired by this post
> >> > http://tsdgeos.blogspot.ru/2014/03/asan-and-libraries-2nd-part.html
> >> >
> >> > I wanted to try the following with ASan:
> >> > 1) create shared library with error -> libshared.so
> >> > 2) create trivial program that used <- libshared.so
> >> >
> >> > $ ls
> >> > main.cpp  shared.cpp  shared.h
> >> >
> >> > $ cat main.cpp
> >> > #include "shared.h"
> >> >
> >> > int main(int, char **)
> >> > {
> >> > Foo f;
> >> > return 0;
> >> > }
> >> >
> >> > $ cat shared.cpp
> >> > #include "shared.h"
> >> >
> >> > Foo::Foo()
> >> > {
> >> > int a[1];
> >> > a[2] = 3;
> >> > }
> >> >
> >> > $ cat shared.h
> >> > class Foo
> >> > {
> >> > public:
> >> > Foo();
> >> > };
> >> >
> >> > $ clang++ --version
> >> > clang version 3.7.0 (trunk 237353)
> >> > Target: x86_64-unknown-linux-gnu
> >> > Thread model: posix
> >> >
> >> > $ clang++ -fno-omit-frame-pointer -fsanitize=address -fPIC -g3 -c
> >> > shared.cpp
> >> > $ clang++ -shared -Wl,--no-undefined -o libshared.so -g3
> >> > -lclang_rt.asan-x86_64 -L /usr/local/lib/clang/3.7.0/lib/linux/
> shared.o
> >>
> >> Why -lclang_rt... ? The usual way is adding -fsanitize=address to both
> >> compilation and linking steps.
> >>
> >> > $ clang++ -fno-omit-frame-pointer -fsanitize=address -lshared -L . -g3
> >> > -Wl,-rpath=/usr/local/lib/clang/3.7.0/lib/linux/ main.cpp
> >> >
> >> > $ LD_LIBRARY_PATH=. ./a.out
> >> > ==14933==Your application is linked against incompatible ASan
> runtimes.
> >> >
> >> > What did I do wrong? Please help.
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "address-sanitizer" group.
> >> > To unsubscribe from this group and stop receiving emails from it, send
> >> > an
> >> > email to [email protected].
> >> > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "address-sanitizer" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "address-sanitizer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Alexey Samsonov, Mountain View, CA

-- 
You received this message because you are subscribed to the Google Groups 
"address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to