address sanitizer won't work with bash on windows

强颜欢笑 提交于 2019-12-19 18:47:34

问题


Currently running llvm, clang, clang-format, and clang-modernize on Ubuntu Bash on Windows. I would like to use the set of sanitize tools released by google including address, memory, and thread sanitize. None of the fsanitize options seem to work.

Here is the code sample for ASAN:

#include <stdlib.h>
int main() {
  char *x = (char *)malloc(10 * sizeof(char *));
  free(x);
  return x[5];// purposely accessing deallocated memory
}

Here is the clang call in bash on windows:

$clang++-3.5 -fsanitize=address -o1 -fno-omit-frame-pointer -g main.cpp -o main
$./main

Results

==70==Sanitizer CHECK failed: build/buildd/llvm-toolchain-snapshot-3.5/projects/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cc:211 ((IsOneOf(*current_, 's', 'p'))) != (0)(0,0)

I'd love suggestions on how to get it working or if I'm missing part of the tool-chain or something.

Failing that I suppose I will dual-boot Ubuntu or Debian, because clang for windows is missing simple features like std:out support, though ideally I'd like to be able to compile both for Windows targets and Linux targets. I'd like to avoid dual-booting though as Ubuntu can't mount windows storage spaces, but they appear to be served to Ubuntu bash on windows quite well.


回答1:


Taking a quick peek at the source code - MemoryMappingLayout::Next - https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_linux.cc - it appears the issue is that bash on ubuntu on windows support for the /proc filesystem is incomplete.

The code that fails is looking at /proc/self/maps - which actually - appears to be about right.

But I've found other stuff (e.g. networking ) in /proc completely broken on bashonwindowsonunix - so I'm pretty sure that part is a work in progress.



来源:https://stackoverflow.com/questions/38111199/address-sanitizer-wont-work-with-bash-on-windows

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