2

I'm trying to use Google sanitizers https://www.jetbrains.com/help/clion/google-sanitizers.html on my CMake project using CLion. I need to pass ASAN_OPTIONS=detect_container_overflow=0 environment variable so that Google sanitizers can pass on the container overflow error. I put "ASAN_OPTIONS=detect_container_overflow=0" in the Run/Debug configuration, but it didn't work, the sanitizer still halt at container_overflow errors and won't proceed.

clion

So I added a new env variable TESTENV=testenv put the following lines in my program to check if it works:

  const char* asan = std::getenv("ASAN_OPTIONS");
  LOG(INFO) << fmt::format("ASAN_OPTIONS {}", asan);

  const char* testEnv = std::getenv("TESTENV");
  LOG(INFO) << fmt::format("TESTENV {}", testEnv);

The output does include TESTENV, but the output of ASAN_OPTIONS doesn't have detect_container_overflow=0:

I20220102 00:34:57.356257 966499840 test.cpp:148] ASAN_OPTIONS detect_stack_use_after_return=false log_path='/private/var/folders/rk/5dyjln0d4551nr1c6q7vz8mc0000gn/T/clion-sanitizersf4b4f3de-dbaf-4dc8-a2fb-fc5f7f2e6138/00f8647a-83ba-4e45-8f4e-2e0c0a45ef9f' stack_trace_format='pc_%p###func_%f###file_%s###line_%l###obj_%M' print_summary='true'
I20220102 00:34:57.356273 966499840 test.cpp:151] TESTENV testenv

I also tried ASAN_OPTIONS=$ASAN_OPTIONS:detect_container_overflow=0 but the output is the same. Can someone help?

fabian
  • 80,457
  • 12
  • 86
  • 114
user2577547
  • 93
  • 1
  • 10

2 Answers2

1

I'm trying to figure out which is the right way. I suppose it should works just by setting the option right in the Sanitizers section (Build, Execution & Deployment > Dynamic Analysis Tools > Sanitizers)

enter image description here

But for some reason this does not work for me, so I have to set it too in the CMake environment section (Build, Execution & Deployment > CMake)

enter image description here

Carlos D. Álvaro
  • 561
  • 1
  • 6
  • 12
  • Thanks for hint where to find this. I was using ENV variables e.g. `ASAN_OPTIONS=detect_odr_violation=1` but it seems that this window in Clion overrides this. It would be nice that they could just WARN user when running that they override some options... – Gelldur Jan 27 '23 at 09:16
0

As shown in the figure, relevant variables should be set here. It's works for me. clion config

yolo992
  • 1
  • 2