Meaningful stack traces for address sanitizer in GCC

后端 未结 3 855
心在旅途
心在旅途 2020-12-05 06:45

I just tried compiling with GCC and the -fsanitize=address flag. When I run my program, the address sanitizer finds a flaw, but the stack trace is not helpful.

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 07:28

    This is what is working for me:

    • Make sure you have installed llvm (including llvm-symbolizer).
    • Export the following variable

      export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer

      (replace with your correct path to the llvm-symbolizer command).

    • Now run your executable (a.out for now) as

      ASAN_OPTIONS=symbolize=1 a.out

提交回复
热议问题