lewisje / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 0 forks source link

support relative paths in backlist files #404

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Paths in backlist files must much paths passed to compiler by build system. 
This is very inconvenient and hard to use. If a build system gives full paths 
to compiler, there is no way to write a portable blacklist file. We need to 
promote usage of relative paths in blacklist files and match them as suffix 
against the source path passed to compiler. Paths must be canonicalized and 
cleaned against ".", ".." dirs, "./" in the beginning, etc.
See the following user request for details:

---------- Forwarded message ----------
From: Ilya Mirsky
Date: Wed, Aug 12, 2015 at 1:24 PM
Subject: Blacklist file
To: thread-sanitizer

Hi,

I discovered a weird behaviour with a blacklist file- it doesn't work if the 
the blacklisted path is absolute and the build string uses relative paths, or 
vice versa. Is it a bug, a feature, or am I missing something here? The 
following 4 scenarios demonstrate this behaviour.

Clang version: 3.7
OS: Ubuntu 12.04, Linux kernel 3.5.0-36

Thanks,
Ilya

1. Relative blacklisting and relative build paths: blacklisting works

mirski@mirski-u12:~/src$ cat demos/tsan/blacklist.tsan 
src:demos/tsan/*

mirski@mirski-u12:~/src$ clang -g -fsanitize=thread 
-fsanitize-blacklist=demos/tsan/blacklist.tsan demos/tsan/race.c
mirski@mirski-u12:~/src$ TSAN_OPTIONS= ./a.out 
Global=42
mirski@mirski-u12:~/src$ 

2. Relative blacklisting and absolute build paths: blacklisting doesn't work

mirski@mirski-u12:~/src$ cat demos/tsan/blacklist.tsan 
src:demos/tsan/*

mirski@mirski-u12:~/src$ clang -g -fsanitize=thread 
-fsanitize-blacklist=demos/tsan/blacklist.tsan 
/home/mirski/src/demos/tsan/race.c
mirski@mirski-u12:~/src$ TSAN_OPTIONS= ./a.out 
==================
WARNING: ThreadSanitizer: data race (pid=31138)
  Read of size 4 at 0x0000014ad4e0 by main thread:
    #0 main /home/mirski/src/demos/tsan/race.c:22:27 (a.out+0x0000004a2eb8)

  Previous write of size 4 at 0x0000014ad4e0 by thread T1:
    #0 Thread1 /home/mirski/src/demos/tsan/race.c:8:12 (a.out+0x0000004a2e11)

  Location is global 'Global' of size 4 at 0x0000014ad4e0 (a.out+0x0000014ad4e0)

  Thread T1 (tid=31140, running) created by main thread at:
    #0 pthread_create /export/local1/mirski/llvm/release_37/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:849 (a.out+0x000000448c83)
    #1 main /home/mirski/src/demos/tsan/race.c:16:5 (a.out+0x0000004a2e78)

SUMMARY: ThreadSanitizer: data race /home/mirski/src/demos/tsan/race.c:22:27 in 
main
==================
Global=42
ThreadSanitizer: reported 1 warnings

3. Absolute blacklisting and absolute build paths: blacklisting works

mirski@mirski-u12:~/src$ cat /home/mirski/src/demos/tsan/blacklist.tsan 
src:/home/mirski/src/demos/tsan/*

mirski@mirski-u12:~/src$ clang -g -fsanitize=thread 
-fsanitize-blacklist=demos/tsan/blacklist.tsan 
/home/mirski/src/demos/tsan/race.c
mirski@mirski-u12:~/src$ TSAN_OPTIONS= ./a.out 
Global=42

4. Absolute blacklisting and relative build paths: blacklisting doesn't work

mirski@mirski-u12:~/src$ cat /home/mirski/src/demos/tsan/blacklist.tsan 
src:/home/mirski/src/demos/tsan/*

mirski@mirski-u12:~/src$ clang -g -fsanitize=thread 
-fsanitize-blacklist=demos/tsan/blacklist.tsan demos/tsan/race.c
mirski@mirski-u12:~/src$ TSAN_OPTIONS= ./a.out 
==================
WARNING: ThreadSanitizer: data race (pid=32632)
  Read of size 4 at 0x0000014ad4e0 by main thread:
    #0 main /home/mirski/src/demos/tsan/race.c:22:27 (a.out+0x0000004a2eb8)

  Previous write of size 4 at 0x0000014ad4e0 by thread T1:
    #0 Thread1 /home/mirski/src/demos/tsan/race.c:8:12 (a.out+0x0000004a2e11)

  Location is global 'Global' of size 4 at 0x0000014ad4e0 (a.out+0x0000014ad4e0)

  Thread T1 (tid=32634, running) created by main thread at:
    #0 pthread_create /export/local1/mirski/llvm/release_37/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:849 (a.out+0x000000448c83)
    #1 main /home/mirski/src/demos/tsan/race.c:16:5 (a.out+0x0000004a2e78)

SUMMARY: ThreadSanitizer: data race /home/mirski/src/demos/tsan/race.c:22:27 in 
main
==================
Global=42
ThreadSanitizer: reported 1 warnings

Original issue reported on code.google.com by dvyu...@google.com on 20 Aug 2015 at 5:31

GoogleCodeExporter commented 9 years ago

Original comment by dvyu...@google.com on 20 Aug 2015 at 6:07