Status: Accepted
Owner: [email protected]
Labels: Type-Defect Priority-Medium

New issue 405 by [email protected]: chdir breaks symbolization of dynamic libraries
https://code.google.com/p/address-sanitizer/issues/detail?id=405

The program is:

// 1.c
#include <unistd.h>
#include <dlfcn.h>

int main() {
  void *handle = dlopen("./s.so", RTLD_LAZY);
  void (*f)() = (void (*)())dlsym(handle, "run");
  chdir("/tmp");  // breaks symbolization
  (*f)();
  return 0;
}

// 2.c
#include <stdlib.h>
void run() {
  void *p = malloc(1);
  *(volatile int *)p = 42;
}

Build as:

$ clang -fsanitize=address 1.c -g
$ clang -fsanitize=address 2.c -o s.so -shared -fPIC -g

When run s.so is not symbolized:

$ ./a.out

==7130==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000efd0 at pc 0x7ffaeaafe7eb bp 0x7ffc4faf8500 sp 0x7ffc4faf84f8
WRITE of size 4 at 0x60200000efd0 thread T0
LLVMSymbolizer: error reading file: No such file or directory.
    #0 0x7ffaeaafe7ea  (s.so+0x7ea)
    #1 0x4ddc24 in main /tmp/111.c:8:3
#2 0x7ffaed3e4ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287 #3 0x4186e5 in _start (/usr/local/google/home/dvyukov/src/llvm/a.out+0x4186e5)

If chdir is commented out, then s.so is symbolized.


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
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