From 2583e0ea02bce62503a5d072d94e641db12d886f Mon Sep 17 00:00:00 2001 From: Marcus Mann Date: Sun, 3 Oct 2021 21:09:51 -0400 Subject: [PATCH] add `export` to `ASAN_OPTIONS` This is needed because the subprocess `clang++` needs to be able to read `ASAN_OPTIONS` and it won't get passed unless it's exported. --- labs/lab02/index.html | 2 +- labs/lab02/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/labs/lab02/index.html b/labs/lab02/index.html index 2c60c188..f418cb1a 100755 --- a/labs/lab02/index.html +++ b/labs/lab02/index.html @@ -275,7 +275,7 @@

Memory Leaks and Corruption

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 brew install llvm
 PROFILE_FILE=$(if [[ -n $ZSH_VERSION ]]; then echo ~/.zshrc; else echo ~/.bash_profile; fi)
-echo 'ASAN_OPTIONS=detect_leaks=1\nexport PATH="/usr/local/opt/llvm/bin:${PATH}"' >> $PROFILE_FILE
+echo 'export ASAN_OPTIONS=detect_leaks=1\nexport PATH="/usr/local/opt/llvm/bin:${PATH}"' >> $PROFILE_FILE
 source $PROFILE_FILE

Now you can compile your code with AddressSanitizer enabled:

clang++ List.cpp ListItr.cpp ListNode.cpp ListTest.cpp -fsanitize=address -fno-omit-frame-pointer -g
diff --git a/labs/lab02/index.md b/labs/lab02/index.md index cadaff17..92cc9804 100755 --- a/labs/lab02/index.md +++ b/labs/lab02/index.md @@ -368,7 +368,7 @@ If you are using Mac OS X (and ONLY if you are using Mac OS X), then you will ne /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew install llvm PROFILE_FILE=$(if [[ -n $ZSH_VERSION ]]; then echo ~/.zshrc; else echo ~/.bash_profile; fi) -echo 'ASAN_OPTIONS=detect_leaks=1\nexport PATH="/usr/local/opt/llvm/bin:${PATH}"' >> $PROFILE_FILE +echo 'export ASAN_OPTIONS=detect_leaks=1\nexport PATH="/usr/local/opt/llvm/bin:${PATH}"' >> $PROFILE_FILE source $PROFILE_FILE ```