What to use instead of mudflap with gcc/llvm (for detecting memory access bugs)?

风格不统一 提交于 2020-01-01 09:16:30

问题


It seems that the -fmudflap feature was removed from GCC.

Thus my question: what to use instead of it for dynamically analyzing programs for out-of-bound read/writes, uninitialized reads and such issues?

(and perhaps as a side question: why was it removed?)

The approach of mudflap (instrumentalizing generated code inside the compiler) looks quite elegant.

Background

Other tools instrumentalize on a machine-code level (e.g. Purify), on a source-code level (e.g. Insure) or instrumentalize during the emulation of a CPU (e.g. Valgrind).

The mudflap approach has the potential to find errors which can't be detected by valgrind or purify (e.g. stack based array access errors). It is also more lightweight than other approaches.

I am searching for an open source solution.


回答1:


It looks like -fsanitize is a direct replacement of -fmudflap. To quote the GCC 4.8.2 man page:

   -fsanitize=address
      Enable AddressSanitizer, a fast memory error detector.  Memory access
      instructions will be instrumented to detect out-of-bounds and use-after-
      free bugs.  See <http://code.google.com/p/address-sanitizer/> for more 
      details.

  -fsanitize=thread
      Enable ThreadSanitizer, a fast data race detector.  Memory access
      instructions will be instrumented to detect data race bugs.  See
      <http://code.google.com/p/data-race-test/wiki/ThreadSanitizer> for 
      more details.

It is also available as part of LLVM (>= 3.1).




回答2:


The sanitizers are also quite a bit more advanced in llvm than in gcc as the primary group contributes to llvm and then someone else ports it over to gcc.

http://llvm.org/devmtg/2012-11/#talk4

Has information given by the authors in 2012 on the sanitizers.



来源:https://stackoverflow.com/questions/19989323/what-to-use-instead-of-mudflap-with-gcc-llvm-for-detecting-memory-access-bugs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!