ldc-developers / ldc

The LLVM-based D Compiler.
http://wiki.dlang.org/LDC
Other
1.21k stars 263 forks source link

Support ASan for Phobos and druntime #3182

Open JohanEngelen opened 5 years ago

JohanEngelen commented 5 years ago

Initial steps:

Example usage:

fun:bad_function_name

src:file_with_tricky_code.cc

Blacklist druntime functions whose inline assembly does not sit well with

ASan yet, see https://github.com/ldc-developers/ldc/issues/2257

fun:_DcallWithStackShell fun:_DgetcacheinfoCPUID2

Functions from the conservative gc druntime

fun:12conservative2gc fun:_D4core5cpuid*


- [ ] Make sure the asan_blacklist.txt files are part of the LDC installation package.
- [ ] Add -fsanitize-blacklist=... for these blacklist files to ldc.conf (user should not need to know about what to blacklist in phobos/druntime)
- [ ] Add simple test that indeed the blacklist is working for phobos and druntime. Tricky: test that blacklisting druntime or phobos is loaded by either `-v` output, or by testing that a function that should _always_ be blacklisted  is indeed not instrumented...
- [ ] Add a CI test of Phobos unittests with ASan enabled. 

Once that is in place: slowly reduce the amount of blacklisting of Phobos and druntime functions! (Expect to make bug fixes!)
JohanEngelen commented 5 years ago

This may help: https://johanengelen.github.io/ldc/2017/12/25/LDC-and-AddressSanitizer.html