[PATCH] D50406: SafeStack: Delay thread stack clean-up

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 8 14:27:08 PDT 2018


eugenis added inline comments.


================
Comment at: lib/safestack/safestack.cc:162
+static thread_stack_ll *thread_stacks = nullptr;
+static pthread_mutex_t thread_stacks_mutex = PTHREAD_MUTEX_INITIALIZER;
+
----------------
vlad.tsyrklevich wrote:
> Wasn't sure if I was allowed to use libpthread from a runtime. I think I could replace the mutex with the __atomic_exchange() built-in if I need to.
We are using it already, so it should be fine.
I think it would only matter if we instrument libc... let's not worry about that for now.


================
Comment at: lib/safestack/safestack.cc:202
+  // Merge thread_stacks with the current thread's stack and any temp_stacks cur_stack+temp_stacks.
+  *stackp = thread_stacks;
+  thread_stacks = cur_stack;
----------------
You are trying to append to the end of temp_stacks list.

But if we managed to destroy all pending stacks, then stackp points to temp_stacks itself, which is a local variable, and this store is dead.




Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D50406





More information about the llvm-commits mailing list