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

rr doesn't get along with address sanitizer #1690

Closed
jrmuizel opened this issue Apr 21, 2016 · 13 comments
Closed

rr doesn't get along with address sanitizer #1690

jrmuizel opened this issue Apr 21, 2016 · 13 comments

Comments

@jrmuizel
Copy link

STR:

  • build a simple program on Ubuntu 15.10 with -fsantizer=address
  • run rr ./simple-program
    get:
    ==20722==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.
@rocallahan
Copy link
Collaborator

I don't get this problem with clang 3.7.0 in Fedora 23. I hit a couple of other bugs, but after fixing those on master, I can now record and replay a trivial ASAN program that triggers a stack overflow report. I'll try it on Ubuntu 15.10 later.

@rocallahan
Copy link
Collaborator

OK, I tried this on up-to-date Ubuntu 15.10 and it worked too. Maybe we need more detailed steps to reproduce your bug?

@rocallahan
Copy link
Collaborator

Here's my test program FWIW:

int main(void) {
  char buf[100];
  int i;
  for (i = 0; i < 101; ++i) {
    buf[i] = 1;
  }
  return 0;
}

@abrowne2
Copy link

I tried replicating this same issue with Ubuntu 14.04 with -fsanitizer=address and the above test program, and it did not produce "==20722==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.", it triggered the report as well.

@jrmuizel
Copy link
Author

Yep. I can't reproduce this anymore either.

@ehsan
Copy link
Contributor

ehsan commented Jun 2, 2016

This can be reproduced with the following compiler which I think is the default on Ubuntu 15.10:

$ cc --version
cc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
$ cc -fsanitize=address test.cc
$ rr ./a.out
rr: Saving the execution of `./a.out' to trace directory `/home/ehsan/.local/share/rr/a.out-1'.
==12305==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.

test.cc is the test program above.

@jrmuizel jrmuizel reopened this Jun 2, 2016
@rocallahan
Copy link
Collaborator

OK, I think to fix this we just need to ensure libasan is added to LD_PRELOAD before librrpreload. librrpreload doesn't need to be the first library loaded (though the earlier it's loaded, the faster things will be).

Probably the most flexible way to do this would be to add a command-line parameter to recording that allows the user to inject an arbitrary string to be inserted into the tracee LD_PRELOAD before librrpreload. This would also let you generally add things tracee LD_PRELOAD without injecting them into rr itself.

It would be more convenient to have rr scan the libraries required by the tracee executable and automatically insert the required LD_PRELOAD so asan just works without any user intervention, but that's a bit more complicated and wouldn't solve some cases.

@rocallahan
Copy link
Collaborator

Then again, if we require a special command line parameter that's not very discoverable :-(.

@rocallahan
Copy link
Collaborator

OK, I implemented the fully automatic approach in dc23125.

@glandium
Copy link
Contributor

glandium commented Dec 3, 2016

I just hit this with rr 4.4 on Debian...

@rocallahan
Copy link
Collaborator

If you run with RR_LOG=RecordSession do you see the "Prepending ... to LD_PRELOAD" message?

@Pamplemousse
Copy link

Pamplemousse commented Jun 30, 2021

I am encountering this error with rr at version 4.5.0, and my binary compiled with clang 11.1.0 and ASAN as a shared library (-fsanitize=address -shared-libasan).

If you run with RR_LOG=RecordSession do you see the "Prepending ... to LD_PRELOAD" message?

No, I don't 😕

@rocallahan
Copy link
Collaborator

This issue is long gone. Please follow #2892 instead.

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

No branches or pull requests

6 participants