Commit Graph

4 Commits

Author SHA1 Message Date
Azat Khuzhin
eb4c095077 Fix suppressions for rd_avg_calc()/rd_avg_rollover() (due to static qualifier)
The problem is that TSan still fails [1] is that ignorelist does not
work for static functions without asterisk:

    // test.cpp
    #include <thread>

    bool flag = false;

    // avoid mangling
    extern "C" {

    static void set_flag_impl()
    {
        flag = true;
    }

    void set_flag()
    {
        set_flag_impl();
    }
    void set_flag_if()
    {
        if (flag)
            flag = false;
    }

    }

    int main()
    {
        std::thread t1([]{ set_flag(); });
        std::thread t2([]{ set_flag_if(); });

        t1.join();
        t2.join();

        return 0;
    }

    // ignorelist
    [thread]
    fun:set_flag_impl

    $ clang++ -g -fno-omit-frame-pointer -fsanitize=thread -fsanitize-ignorelist=ignorelist -o test test.cpp && ./test
    SUMMARY: ThreadSanitizer: data race /tmp/test-tsan-ignorelist/test.cpp:19:9 in set_flag_if
    $ sed -i 's/set_flag_impl/*set_flag_impl*/' ignorelist
    $ clang++ -g -fno-omit-frame-pointer -fsanitize=thread -fsanitize-ignorelist=ignorelist -o test test.cpp && ./test
    OK

But, note that ignorelist is tricky, and will not work for
functions with __always_inline__ attribute for example.

P.S. set_flag_impl also has brackets in the output (i.e.
set_flag_impl()), while ther eis brackets for rd_avg_calc on CI [1].

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/63039/84bebc534ba7cf6e9dbfc1d91e8350939a84f87c/integration_tests__tsan__[6_6]//home/ubuntu/actions-runner/_work/_temp/test/output_dir/integration_run_parallel4_0.log

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2024-04-27 09:51:59 +02:00
Azat Khuzhin
84bebc534b Fix suppressions for librdkafka data-race for statistics code
The problem is that ignorelist `fun` does not work recursively.

<details>

<summary>example</summary>

```c
// test.cpp

bool flag = false;

// avoid mangling
extern "C" {

void set_flag_impl()
{
    flag = true;
}
void set_flag()
{
    set_flag_impl();
}
void set_flag_if()
{
    if (flag)
        flag = false;
}

}

int main()
{
    std::thread t1([]{ set_flag(); });
    std::thread t2([]{ set_flag_if(); });

    t1.join();
    t2.join();

    return 0;
}
```

```
// ignorelist
[thread]
fun:set_flag
```

```
$ clang++ -g -fno-omit-frame-pointer -fsanitize=thread -fsanitize-ignorelist=ignorelist -o test test.cpp && ./test
SUMMARY: ThreadSanitizer: data race /tmp/tsan-test/test.cpp:18:9 in set_flag_if
$ sed -i 's/set_flag/set_flag_impl/' ignorelist
$ clang++ -g -fno-omit-frame-pointer -fsanitize=thread -fsanitize-ignorelist=ignorelist -o test test.cpp && ./test
OK
```

</details>

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2024-04-26 16:08:45 +03:00
Azat Khuzhin
6e534650e4 Use sanitizer specific ignorelists
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2024-04-26 15:46:04 +03:00
Azat Khuzhin
90e1f7d8ec Fix sanitizers suppressions
The -fsanitize-ignorelist (-fsanitize-blacklist is the alias for it)
accepts not the suppressions but special case list, that accept only
`fun` and `src`, so convert tsan_suppressions.txt into a proper
tsan_ignorelist.txt with a proper syntax, otherwise suppressions simply
does not work [1].

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/61526/958659584957ff419a9305d9c7edee5703fedbdc/integration_tests__tsan__[6_6].html

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2024-03-24 16:22:23 +01:00