How to use thread-sanitizer of gcc v4.8.1?

后端 未结 1 1356
陌清茗
陌清茗 2021-02-06 06:34

gcc v4.8.x add options for debugging your program:

-fsanitize=thread

Enable ThreadSanitizer, a fast data race detector. Memory access instructions wil

相关标签:
1条回答
  • 2021-02-06 07:24

    I did some exploration:

    1. I found the following on http://gcc.gnu.org/gcc-4.8/changes.html:

    ThreadSanitizer has been added and can be enabled via -fsanitize=thread. Instructions will be instrumented to detect data races. The ThreadSanitizer is available on x86-64 GNU/Linux.

    -fsanitize=thread is only supported on 64 bit CPU. My linux uname -a outputs:

    Linux hl.zy 3.9.8-300.fc19.i686 #1 SMP Thu Jun 27 19:40:39 UTC 2013 i686 i686 i386 GNU/Linux

    My CPU is 32 bit, It's not supported!

    1. I checked the compiler configuration, as Jonathan Leffler said

    below is output of "gcc -dumpspecs | grep tsan":

    %{fsanitize=thread:%{static-libtsan:%{!shared:-Bstatic --whole-archive \
      -ltsan --no-whole-archive -Bdynamic}}%{!static-libtsan:-ltsan}}}} %o 
    

    But I don't understand the output.

    1. I have install Fedora 19 64 bit, you can install libtsan:

      sudo yum install libtsan.x86_64
      

    Concusion:

    -fsanitize=thread is only supported on 64 bit gcc now.

    0 讨论(0)
提交回复
热议问题