[libc-commits] [PATCH] D75380: [libc] Add linux implementations of thrd_create and thrd_join functions.

Alex Brachet via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Mar 2 19:03:29 PST 2020

abrachet added inline comments.

Comment at: libc/src/threads/linux/thrd_create.cpp:27
+static void start_thread(thrd_t *thread, thrd_start_t func, void *arg) {
+  __llvm_libc::syscall(SYS_exit, thread->__retval = func(arg));
sivachandra wrote:
> abrachet wrote:
> > Make this `[[noreturn]]`
> Sanitizers blow up at this point. I do not understand sanitizers enough yet to explain why. I will be sharing a more holistic treatment of sanitizers in LLVM-libc soon so I will try to include talking about this there.
> FWIW, I have shared this problem with the sanitizer experts I have access to and they are investigating.
I have tried this and it is failing for me too, on a clang and compiler-rt built a few days ago. If I had to take a guess, and it really is just that, I've gone through it with lldb a couple of times and played around a bit, is that we aren't setting up tls right now which is messing with asan when it calls `__asan_handle_no_return`. If you try this with `pthread_create` or `std::thread` it works fine. If you make `start_thread` and `thrd_create` `__attribute__((no_sanitize("undefined"), no_sanitize("address"))` it  also obviously stops the crashes.

I tried making the function we pass to `thrd_create` make calls to asan by making memory reads (`__asan_report_store`) etc, it doesn't crash but perhaps future tests might.

Comment at: libc/test/src/threads/linux/thrd_test.cpp:1
+//===---------------------- Unittests for thrd_t --------------------------===//
Should this be in a linux specific directory for tests?

  rG LLVM Github Monorepo



More information about the libc-commits mailing list