address-sanitizer

Getting undefined symbol: __asan_memset when trying to use Clang address sanitizer

倖福魔咒の 提交于 2019-12-11 01:17:45
问题 I'm trying to use address sanitizer with clang to compile a C++ application but getting the following error: /Class.so: undefined symbol: __asan_memset I have added -fsanitize=address to the compiler flags /opt/llvm-3.8.0/bin/clang++ -M --gcc-toolchain=/opt/gcc-5.2.0 -fsanitize=address and I have added -fsanitize=address and -lasan to the linker flags: -fsanitize=address -lasan -shared -fuse-ld=gold-2.25 -o Class.so Class.o What else do I need to do to get this to work? 回答1: You main

Can MEX files be run with -fsanitize=address?

纵饮孤独 提交于 2019-12-10 19:24:05
问题 I have a MEX file compiled normally with g++. I recently changed its compilation to use clang++, and included -fsanitize=address into both the LDFLAGS and CFLAGS (note: no CXX flags exist for this project). However, despite this, once I get to MATLAB and attempt to call the MEX file, I get: Invalid MEX-file '(path to mex file)': undefined symbol: __asan_option_detect_stack_use_after_return. That specific error is really common when people mess up linking in the address sanitizer correctly.

Why does Xcode define _LIBCPP_HAS_NO_ASAN when creating an address-sanitized build?

旧街凉风 提交于 2019-12-10 06:28:39
问题 Xcode 7 allows address sanitizer to be used to find memory issues in C/C++. https://github.com/google/sanitizers/wiki/AddressSanitizer Turning on address sanitizer passes the compile and linker flag -fsanitize=address and also defines _LIBCPP_HAS_NO_ASAN . When building my library from the command line and running tests on a sanitized build without defining _LIBCPP_HAS_NO_ASAN I see non-repeatable address-sanitizer-reported memory access issues. Defining _LIBCPP_HAS_NO_ASAN , as Xcode does,

How do I make LeakSanitizer ignore end of program leaks

天大地大妈咪最大 提交于 2019-12-09 13:33:09
问题 I want to use LeakSanitizer to detect leaked memory, but the style of the program I am using does not free memory before exit . This is fairly common in my experience. I want to detect this leak: int main(int argc, char const *argv[]) { char *p = malloc(5); p = 0; return 0; } And ignore this leak: int main(int argc, char const *argv[]) { char *p = malloc(5); return 0; } 回答1: You want LSan to report only unreachable leaks i.e. pointers which are guaranteed to be leaked by the program. Problem

Why is “Enable Address Sanitizer” disabled in Xcode 7?

喜夏-厌秋 提交于 2019-12-08 15:38:27
问题 I read about the Runtime Sanitization in the Apple docs in the new Xcode 7, so I looked for it, and found that it's disabled. I'm using Xcode 7 GM seed. When I go into the Run action of the scheme > Diagnostics tab, the Enable Address Sanitizer option is disabled: There is some explanation about how other options are disbled, but no mention of why the sanitization option would be disabled: Some diagnostic tools can be used in combination with others; the options available on the Diagnostics

How can I use cmake to test processes that are expected to fail with an exception? (e.g., failures due to clang's address sanitizer)

你离开我真会死。 提交于 2019-12-07 12:16:38
问题 I've got some tests that test that clang's address sanitizer catch particular errors. (I want to ensure my understanding of the types of error it can catch is correct, and that future versions continue to catch the type of errors I'm expecting them to.) This means I have several tests that fail by crapping out with an OTHER_FAULT , which appears to be the fixed way that clang's runtime reports an error. I've set the WILL_FAIL flag to TRUE for these tests, but this only seems to check the

AddressSanitizer / LeakSanitizer Error with -lsupc++ and -stdlib=libc++ on a never called virtual function that writes to a stream

萝らか妹 提交于 2019-12-06 11:28:36
The following code throws an AddressSanitizer Error when compiled on Debian Jessie with clang 3.5. It appears to be related to the combination of linked libraries, but i have not been able to find something similar on the internet. Reproduction of the Error Invocation: clang++ -stdlib=libc++ -lc++abi -fsanitize=address,vptr sample.cpp -lsupc++ -o sample //sample.cpp #include <iostream> class Foo { virtual void bar() { std::cerr << std::endl; } public: virtual ~Foo() { } }; int main() { Foo foo; try{ throw 1; } catch(int i) { return i; } return -1; } When omitting compile flag -lc++abi , a

Why does Xcode define _LIBCPP_HAS_NO_ASAN when creating an address-sanitized build?

为君一笑 提交于 2019-12-05 18:05:14
Xcode 7 allows address sanitizer to be used to find memory issues in C/C++. https://github.com/google/sanitizers/wiki/AddressSanitizer Turning on address sanitizer passes the compile and linker flag -fsanitize=address and also defines _LIBCPP_HAS_NO_ASAN . When building my library from the command line and running tests on a sanitized build without defining _LIBCPP_HAS_NO_ASAN I see non-repeatable address-sanitizer-reported memory access issues. Defining _LIBCPP_HAS_NO_ASAN , as Xcode does, gets rid of the sanitizer issues but I'm curious as to why it needs doing. Why do I need to define

android studio address sanitizer using build.gradle

一曲冷凌霜 提交于 2019-12-05 05:36:03
问题 I am trying to build (with clang) my application with the address sanitizer described here (https://github.com/google/sanitizers/wiki/AddressSanitizer, more precisely here: https://github.com/google/sanitizers/wiki/AddressSanitizerOnAndroid), but I am having trouble understanding the whole process, especially using gradle. It looks like there is at least 3 ways of enabling it: 1°) Following the first link, t says that all you have to do is doing this: adding -fsanitize=address to the cppFlags

How do I get line numbers in the debug output with clang's -fsanitize=address?

巧了我就是萌 提交于 2019-12-04 17:44:31
问题 I am trying to debug a memory error detected by clang with asan , but missed by valgrind . But I cannot get my clang built binary to give me any useful debugging information. I can demonstrate this with a short test program: #include <stdlib.h> #include <string.h> int main(void) { char *a = malloc(8); memset(a, 0, 9); free(a); return 0; } (Obviously this error will be picked up by valgrind , it's purely to show the problem with clang .) I compile it with Clang 3.4-1ubuntu1 like so: clang