for the usage of the ThreadSanitizer

176 views
Skip to first unread message

吕飞飞

unread,
Nov 26, 2020, 7:53:27 AM11/26/20
to thread-sanitizer
Dear sir(or lady),
 
I am a tester of a massive project in a Chinese enterprise. I utilized the ThreadSanitizer which is a really brilliant tool to find more inner problems inside my project. After using your tool, some code problems were discovered. However, I'm willing to find more other problems, so I have some questions for the usage of the ThreadSanitizer.
    1.    When I used the ThreadSanitizer to detect data race problems, I found that some problems were pointing to the same line of the code. How can I find more problems in the project or how can the detector point to a specific task in the whole project?
    2.    If I only want to detect the read and write concurrency issues in the project, how to use your tool to implement it?
I am really look forward to hearing from you! Thank you!
 
Sincerely,
Lvfeifei
Email address

Dmitry Vyukov

unread,
Nov 27, 2020, 2:02:37 AM11/27/20
to 吕飞飞, thread-sanitizer
On Thu, Nov 26, 2020 at 1:53 PM 吕飞飞 <8654...@qq.com> wrote:
>
> Dear sir(or lady),
>
> I am a tester of a massive project in a Chinese enterprise. I utilized the ThreadSanitizer which is a really brilliant tool to find more inner problems inside my project. After using your tool, some code problems were discovered. However, I'm willing to find more other problems, so I have some questions for the usage of the ThreadSanitizer.
> 1. When I used the ThreadSanitizer to detect data race problems, I found that some problems were pointing to the same line of the code.

Hi Lvfeifei,

Several problems pointing to the same line of code should not prevent
ThreadSanitizer from finding other data races. Or how does it create a
problem?
Overall the recommended way is to fix the data races, then
ThreadSanitizer will not produce reports anymore :)
ThreadSanitizer also supports suppression files:
https://github.com/google/sanitizers/wiki/ThreadSanitizerSuppressions


> How can I find more problems in the project or how can the detector point to a specific task in the whole project?

To test only a single task/process, you need to build only this
process with -fsanitize=thread.


> 2. If I only want to detect the read and write concurrency issues in the project, how to use your tool to implement it?

I am not sure I understand the question. What do you mean by "read and
write concurrency issues"? What other types of issues ThreadSanitizer
detects?

吕飞飞

unread,
Jan 12, 2021, 10:07:31 PM1/12/21
to Dmitry Vyukov, thread-sanitizer
Dear sir(or lady),

I'm sorry to bother you again. I sent you an e-mail last year about some problems when using ThreadSanitizer and I really appreciated your reply. Currently, I have some other problems about the ThreadSanitizer. Hope you can help me to solve the following problems.
1. When starting the service, there is no error message when adding the parameter TSAN_OPTIONS="report_bugs=0", and no error message will be output when running the service. I want to output the error message when it is running. What should I do? 
2. I tried to use ThreadSanitizerSuppressions offline to shield unnecessary errors, but it is not very useful. It needs to add a lot of content, some of which are not effective yet. Could you give my some advice about how to solve this problem?
3. Threadsanitizer was introduced when compiling C++ programs offline, but concurrent reading and writing problems were not found when running the program. Is this tool suitable for finding problems related to concurrent reading and writing?
I am really look forward to hearing from you! Thank you!
 
Sincerely,
Lvfeifei


------------------ 原始邮件 ------------------
发件人: "Dmitry Vyukov" <dvy...@google.com>;
发送时间: 2020年11月27日(星期五) 下午3:02
收件人: "吕飞飞"<8654...@qq.com>;
抄送: "thread-sanitizer"<thread-s...@googlegroups.com>;
主题: Re: for the usage of the ThreadSanitizer

Dmitry Vyukov

unread,
Jan 14, 2021, 6:16:05 AM1/14/21
to 吕飞飞, thread-sanitizer
On Wed, Jan 13, 2021 at 4:07 AM 吕飞飞 <8654...@qq.com> wrote:
>
> Dear sir(or lady),
>
> I'm sorry to bother you again. I sent you an e-mail last year about some problems when using ThreadSanitizer and I really appreciated your reply. Currently, I have some other problems about the ThreadSanitizer. Hope you can help me to solve the following problems.
> 1. When starting the service, there is no error message when adding the parameter TSAN_OPTIONS="report_bugs=0", and no error message will be output when running the service. I want to output the error message when it is running. What should I do?

Hi Lvfeifei,

If you want tsan to print something on program start you can add
TSAN_OPTIONS="report_bugs=0 verbosity=1".
Or otherwise print something right in you program, both gcc and clang
allow to detect when compiling with tsan enabled.

> 2. I tried to use ThreadSanitizerSuppressions offline to shield unnecessary errors, but it is not very useful. It needs to add a lot of content, some of which are not effective yet. Could you give my some advice about how to solve this problem?

If a program has lots of bugs, generally there is no good solution
other than fixing these bugs.
Having said that, tsan suppressions match substrings in all frames in
all stacks, so if you add something like "race: libfoo", it should
suppress all races that mention libfoo anywhere. Though, it may
suppress some reports that are not directly related to libfoo as well.

> 3. Threadsanitizer was introduced when compiling C++ programs offline, but concurrent reading and writing problems were not found when running the program. Is this tool suitable for finding problems related to concurrent reading and writing?

Find data races (which concurrent reads and writes) is the main and
the only thing tsan does.
But reading you previous statements it seems that tsan detect lots of
races for you, so I am not sure why you are also saying that it's not
detecting races... Maybe you are asking something else?
Reply all
Reply to author
Forward
0 new messages