Questions tagged [sanitizer]

Sanitizers are a compiler feature supported by Clang and GCC for instrumenting programs to do dynamic analysis and catch many classes of bugs at runtime.

Sanitizers are a compiler feature supported by Clang and GCC for instrumenting programs to do dynamic analysis. There are sanitizers to detect many issues, including many C and C++ "undefined behaviors", signed integer arithmetic overflow, memory allocation errors, use of uninitialized memory, and data races between threads.

These checks can be enabled at compile time using the -fsanitize= option (for example, -fsanitize=address).

The following sanitizers are supported:

More information on the sanitizers development can be found at http://compiler-rt.llvm.org/.

The current list of supported options can be found in the compiler documentation:

120 questions
5
votes
1 answer

How use Memory Sanitizer with use GCC?

I want to use this kind of sanitizer in gcc. How can I do this? Is such an operation possible? I found solution for clang: clang -fsanitize=memory -fno-omit-frame-pointer -g -O2 umr.cc but I don't know how use this in gcc
xyz12345
  • 51
  • 4
5
votes
1 answer

Is passing an absent assumed-shape array for an optional argument of another procedure allowed?

In this minimal example, is it allowed to pass the optional dummy argument y of test_wrapper that may not be present as actual argument for the corresponding optional dummy argument y of test? program main implicit none real :: x = 5.0 …
5
votes
0 answers

Suppress specific sanitizer check, but still fail program on all others

I would like to suppress one error in a third-party library, but still have the program exit 1 on any other failed check. It seems to me that -fno-sanitize-recover will exit the program regardless of the suppressions file's contents. With…
Laurenz
  • 1,810
  • 12
  • 25
5
votes
1 answer

Understanding a runtime error triggered by the undefined behavior sanitizer (UBSan)

I find a run-time error in GNU Scientific Library (GSL) when undefined sanitizer is enabled: deque.c:58:11: runtime error: member access within misaligned address 0x0000024010f4 for type 'struct deque', which requires 8 byte…
zell
  • 9,830
  • 10
  • 62
  • 115
5
votes
2 answers

Angular Dom Sanitizer HTML cannot copy text

I used DomSanitizer to sanitize my HTML content from database to be displayed on page.
Where safeHtml is: safeHtml(html){ return this.sanitize.bypassSecurityTrustHtml(html); } It works perfect.…
5
votes
1 answer

Manual poisoning of std::vector

In the following code snippet there is an error that is not trivial but I would have expected tools like AddressSanitizer to catch it. #include #include int main () { std::vector toto; toto.push_back(2); int const& titi…
moeryn
  • 198
  • 2
  • 12
5
votes
1 answer

asan with g++ 5.4.0 not working on travis CI

until recently my builds with g++ 5 on travis using the address sanitizer were passing - in the past week they broke. I see that the version of g++ is bumped from (Ubuntu 5.2.1-23ubuntu1~12.04) 5.2.1 20151031 to (Ubuntu 5.4.0-3ubuntu1~12.04) 5.4.0…
onqtam
  • 4,356
  • 2
  • 28
  • 50
5
votes
2 answers

How can I know if Leak Sanitizer is enabled at compile time?

The GCC and Clang compilers both have support for LeakSanitizer which helps finding memory leaks in C programs. Sometimes a memory leak is unavoidable (because it is being tested in a test suite for example). Such memory can be annotated using the…
Lekensteyn
  • 64,486
  • 22
  • 159
  • 192
4
votes
1 answer

Why does the clang sanitizer think this left shift of an unsigned number is undefined?

I know there are many similar questions on SO. Please read carefully before calling this a dup. If it is, I would be happy to get a reference to the relevant question. It seems to me that the clang sanitizer is complaining about a perfectly valid…
Ben Ylvisaker
  • 733
  • 6
  • 8
4
votes
0 answers

Is there any alternative to vmlens, to help detect race conditions?

I was looking for a race detector for java code. So far, I only found vmlens (http://vmlens.com/). Is there other options I can choose from?
Slacker
  • 177
  • 1
  • 9
4
votes
0 answers

Clang undefined behavior sanitizer in shared library (JNI): "undefined symbol: __ubsan_vptr_type_cache"

Our clang++ build of executables with undefined behavior sanitizer works fine for executables when compiled as follows: ccache clang++ -Qunused-arguments -fcolor-diagnostics -c -MMD -MP -std=c++11 --O1 -g3 -fPIC -fsanitize=address,undefined…
Pascal Kesseli
  • 1,620
  • 1
  • 21
  • 37
4
votes
2 answers

cause of: AddressSanitizer: SEGV on unknown address (null pointer)

I need some advice how to identify the source of the segfault. compiled with ASAN: ==21093==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f09d744d882 bp 0x000000001000 sp 0x62100001c538…
xlrg
  • 1,994
  • 1
  • 16
  • 14
4
votes
0 answers

Is -fsanitize=bounds-strict included in -fsanitize=undefined for GCC 6?

I'm working on a problem report for a C++ library compiled with GCC 6. I'm reading through the GCC 6 Changes, New Features, and Fixes, and one of the notes is: UndefinedBehaviorSanitizer gained a new sanitization option, -fsanitize=bounds-strict,…
jww
  • 97,681
  • 90
  • 411
  • 885
3
votes
2 answers

Is it necessary to add missing closing tags as part of sanitizing the HTML to prevent XSS attacks?

I'm using the Sanitize gem to disallow HTML code that could be used for an XSS attack. As a side effect, the HTML also gets cleaned up. Missing closing tags get added. This would normally be fine but in many cases it changes the formatting of the…
andy318
  • 542
  • 4
  • 8
3
votes
0 answers

Clang++ LSAN and UBSAN causes undefined reference to `__ubsan_handle_add_overflow'

When I was playing with compiler sanitizers, I was confused by this linking error when only LSAN and UBSAN are enabled on clang++. Note that the linking problem disappeared when I removed -fsanitize=leak or added these flags together:…
jerryc05
  • 454
  • 1
  • 4
  • 16