ClickHouse/dbms/tests/instructions/sanitizers.md

72 lines
1.7 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
```
mkdir build_asan && cd build_asan
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
```
mkdir build_tsan && cd build_tsan
2018-03-03 19:50:02 +00:00
```
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
## 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,suppressions=../dbms/tests/tsan_suppressions.txt' ./clickhouse-tsan server --config /etc/clickhouse-server/config.xml
2018-03-03 19:50:02 +00:00
```
# How to use Undefined Behaviour Sanitizer
2018-03-03 19:50:02 +00:00
```
2019-01-06 16:43:46 +00:00
mkdir build_ubsan && cd build_ubsan
```
2018-03-03 19:50:02 +00:00
2018-12-27 23:53:09 +00:00
Note: clang is mandatory, because gcc (in version 8) has false positives due to devirtualization and it has less amount of checks.
```
2019-01-06 16:43:46 +00:00
CC=clang CXX=clang++ cmake -D SANITIZE=undefined ..
ninja
2018-03-03 19:50:02 +00:00
```
## Start ClickHouse and run tests
2018-03-03 19:50:02 +00:00
```
sudo -u clickhouse UBSAN_OPTIONS='print_stacktrace=1' ./clickhouse-ubsan server --config /etc/clickhouse-server/config.xml
2018-03-03 19:50:02 +00:00
```
# How to use Memory Sanitizer
2018-12-28 04:40:28 +00:00
```
2019-07-25 01:07:58 +00:00
CC=clang-8 CXX=clang++-8 cmake -D ENABLE_HDFS=0 -D ENABLE_CAPNP=0 -D ENABLE_RDKAFKA=0 -D ENABLE_ICU=0 -D ENABLE_POCO_MONGODB=0 -D ENABLE_POCO_NETSSL=0 -D ENABLE_POCO_ODBC=0 -D ENABLE_ODBC=0 -D ENABLE_MYSQL=0 -D ENABLE_EMBEDDED_COMPILER=0 -D USE_INTERNAL_CAPNP_LIBRARY=0 -D USE_SIMDJSON=0 -DENABLE_READLINE=0 -D SANITIZE=memory ..
2018-12-28 04:40:28 +00:00
```