Skip to content

support relative paths in backlist files #404

Open
@ramosian-glider

Description

@ramosian-glider

Originally reported on Google Code with ID 404

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

Reported by [email protected] on 2015-08-20 17:31:47

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions