MINGW-packages: AddressSanitizer does not appear to be available for mingw-w64-x86_64-gcc

OS: Windows 10 x64, version 1703 (build 15063.726)

Steps to reproduce:

  1. Install MSYS2, default values
  2. Update MSYS2, pacman -Syyu, use ctrl+C to close pacman then close window
  3. Update MSYS2 again, pacman -Syyu
  4. Install GCC and nano, pacman -Sy mingw-w64-x86_64-gcc nano
  5. Open a MinGW 64bit session from the Start menu
  6. Open nano to create a new .cpp file, nano test.cpp
  7. Paste following code into nano,
int main(int argc, char **argv) {
  int *array = new int[100];
  array[0] = 0;
  int res = array[argc + 100];  // BOOM
  delete [] array;
  return res;
}
  1. Try to compile, g++ -fsanitize=address -O1 test.cpp -o test

Output:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lasan
collect2.exe: error: ld returned 1 exit status

So, is AddressSanitizer available within the MinGW-w64 project?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 19
  • Comments: 22

Commits related to this issue

Most upvoted comments

hey follks

I don’t want to use CL. I dont know. I’m compiling everything with GCC (mingw-w64).

What are the tools I can use in Windows to detect memory leaks?

Sanitizers are not supported by GCC on Windows.

Let me clarify it: what benefit do you expect from using Clang+sanitizers in mingw64 environment compared to Clang+sanitizers in clang64 environment?

I m also facing the same issue.I didn’t got any solution for that. I m also trying to build clang from Mingw on windows , It is giving error that I cant find any solution.Please let me know If you guys find any solution