ClickHouse/dbms/tests/instructions/sanitizers.md

78 lines
1.5 KiB
Markdown
Raw Normal View History

2017-12-21 02:31:32 +00:00
# How to use Address Sanitizer
2018-03-03 19:51:21 +00:00
Note: We use Address Sanitizer to run functional tests for every commit automatically.
2017-12-21 02:31:32 +00:00
2018-03-03 19:51:21 +00:00
```
2017-12-21 02:31:32 +00:00
mkdir build && cd build
2018-03-03 19:51:21 +00:00
```
2017-12-21 02:31:32 +00:00
2018-08-08 03:42:35 +00:00
Note: using clang instead of gcc is strongly recommended.
2017-12-21 02:31:32 +00:00
2018-03-03 19:50:02 +00:00
```
2018-08-08 03:42:35 +00:00
CC=clang CXX=clang++ cmake -D SANITIZE=address ..
ninja
2018-03-03 19:50:02 +00:00
```
2017-12-21 02:31:32 +00:00
2018-03-03 19:51:21 +00:00
## Copy binary to your server
2017-12-21 02:31:32 +00:00
2018-03-03 19:50:02 +00:00
```
2018-06-05 20:09:51 +00:00
scp ./dbms/programs/clickhouse yourserver:~/clickhouse-asan
2018-03-03 19:50:02 +00:00
```
2017-12-21 02:31:32 +00:00
2018-03-03 19:51:21 +00:00
## Start ClickHouse and run tests
2017-12-21 02:31:32 +00:00
2018-03-03 19:50:02 +00:00
```
2018-03-03 14:42:45 +00:00
sudo -u clickhouse ./clickhouse-asan server --config /etc/clickhouse-server/config.xml
2018-03-03 19:50:02 +00:00
```
2017-12-21 02:31:32 +00:00
# How to use Thread Sanitizer
2018-03-03 19:50:02 +00:00
```
2017-12-21 02:31:32 +00:00
mkdir build && cd build
2018-03-03 19:50:02 +00:00
```
2017-12-21 02:31:32 +00:00
2018-03-03 19:51:21 +00:00
## Note: All parameters are mandatory.
2017-12-21 02:31:32 +00:00
2018-03-03 19:50:02 +00:00
```
2018-08-08 03:42:35 +00:00
CC=clang CXX=clang++ cmake -D SANITIZE=thread ..
ninja
2018-03-03 19:50:02 +00:00
```
2017-12-21 02:31:32 +00:00
2018-03-03 19:51:21 +00:00
## Copy binary to your server
2017-12-21 02:31:32 +00:00
2018-03-03 19:50:02 +00:00
```
2018-06-05 20:09:51 +00:00
scp ./dbms/programs/clickhouse yourserver:~/clickhouse-tsan
2018-03-03 19:50:02 +00:00
```
2017-12-21 02:31:32 +00:00
2018-03-03 19:51:21 +00:00
## Start ClickHouse and run tests
2017-12-21 02:31:32 +00:00
2018-03-03 19:50:02 +00:00
```
sudo -u clickhouse TSAN_OPTIONS='halt_on_error=1' ./clickhouse-tsan server --config /etc/clickhouse-server/config.xml
2018-03-03 19:50:02 +00:00
```
# How to use Memory Sanitizer
First, build libc++ with MSan:
```
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
(cd llvm/projects && svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx)
(cd llvm/projects && svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi)
mkdir libcxx_msan && cd libcxx_msan
cmake ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_SANITIZER=Memory -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
make cxx -j24
```
Then, build ClickHouse:
```
mkdir build && cd build
```
```
2018-08-08 03:42:35 +00:00
CC=clang CXX=clang++ cmake -D SANITIZE=memory -D LIBCXX_PATH=/home/milovidov/libcxx_msan ..
2018-03-03 19:50:02 +00:00
```