-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc++] Don't try to wait on a thread that hasn't started in std::async #125433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++] Don't try to wait on a thread that hasn't started in std::async #125433
Conversation
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesIf the creation of a thread fails, this causes an idle loop that will never end because the thread wasn't started in the first place. Fixes #125428 Full diff: https://github.com/llvm/llvm-project/pull/125433.diff 2 Files Affected:
diff --git a/libcxx/include/future b/libcxx/include/future
index db1f624244b8f77..514d4c3d633d6cf 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -865,7 +865,8 @@ void __async_assoc_state<_Rp, _Fp>::__execute() {
template <class _Rp, class _Fp>
void __async_assoc_state<_Rp, _Fp>::__on_zero_shared() _NOEXCEPT {
- this->wait();
+ if (base::__state_ & base::__constructed)
+ this->wait();
base::__on_zero_shared();
}
@@ -902,7 +903,8 @@ void __async_assoc_state<void, _Fp>::__execute() {
template <class _Fp>
void __async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT {
- this->wait();
+ if (base::__state_ & base::__constructed)
+ this->wait();
base::__on_zero_shared();
}
diff --git a/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp b/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
new file mode 100644
index 000000000000000..ac5db590dbd8d1d
--- /dev/null
+++ b/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: no-threads
+
+// There is no way to limit the number of threads on windows
+// UNSUPPORTED: msvc
+
+#include <cassert>
+#include <future>
+#include <system_error>
+
+#if __has_include(<sys/resource.h>)
+# include <sys/resource.h>
+# ifdef RLIMIT_NPROC
+void force_thread_creation_failure() {
+ rlimit lim = {1, 1};
+ setrlimit(RLIMIT_NPROC, &lim);
+}
+# else
+# error "No known way to force only one thread being available"
+# endif
+#else
+# error "No known way to force only one thread being available"
+#endif
+
+int main() {
+ force_thread_creation_failure();
+
+ try {
+ auto fut = std::async(std::launch::async, [] { return 1; });
+ assert(false);
+ } catch (const std::system_error&) {
+ }
+
+ try {
+ auto fut = std::async(std::launch::async, [] { return; });
+ assert(false);
+ } catch (const std::system_error&) {
+ }
+}
|
5504050
to
d1944d4
Compare
libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
Show resolved
Hide resolved
libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
Show resolved
Hide resolved
ab20aa6
to
b20ce83
Compare
b20ce83
to
cc88f55
Compare
cc88f55
to
16cec3e
Compare
Thank you very much for this quick fix |
You're welcome! |
Fixes hwasan buildbot failure (https://lab.llvm.org/buildbot/#/builders/55/builds/7536/steps/10/logs/stdio) introduced in llvm#125433 by excluding this test for hwasan, similar to the existing exclusion of asan.
Fixes hwasan buildbot failure (https://lab.llvm.org/buildbot/#/builders/55/builds/7536/steps/10/logs/stdio) introduced in #125433 by excluding this test for hwasan, similar to the existing exclusion of asan.
Fixes hwasan buildbot failure (https://lab.llvm.org/buildbot/#/builders/55/builds/7536/steps/10/logs/stdio) introduced in llvm/llvm-project#125433 by excluding this test for hwasan, similar to the existing exclusion of asan.
This looks like the only plausible change in a blamelist for a Fuchsia test regression when trying to roll HEAD clang: It includes the error If this is the culprit, it's either an issue with this change generally or with our usage of |
I guess it's possible if somehow the |
A bit more information; I was able to pull this stack trace:
|
hi folks, we've also started seeing some use-after-free issues after this patch in clangd. I've sent out https://github.com/llvm/llvm-project/pull/130077/files to stop the bleeding for now, but I feel like there's something off with this change. Pattern in clangd looks like: void bar() {
std::future<...> x = std::async(std::launch::async, [some_state]{ // uses some_state; });
// destruct x, don't block explicitly for completion of async task. relying on
} after this patch destructor doesn't block on completion of async task in the future, as a result we free so this code is relying on:
I am not an expert here, so my reading of the standard might be wrong hence I am leaving the final call to you folks. but I feel like this is a rather common pattern and changing behavior here might yield breakages in existing code. Moreover patch description mentions full asan failure=================================================================
==3188==ERROR: AddressSanitizer: heap-use-after-free on address 0x7c72c1ac8c40 at pc 0x7f5736d7521b bp 0x7b52a9c39dc0 sp 0x7b52a9c39db8
READ of size 8 at 0x7c72c1ac8c40 thread T49
#0 0x7f5736d7521a in __invoke<void (std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h:130](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h?l=130&ws=eaeltsin/6692&snapshot=611):7), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context> >::*)(), std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h:130](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h?l=130&ws=eaeltsin/6692&snapshot=611):7), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context> > *, void> [third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__type_traits/invoke.h:147](https://cs.corp.google.com/piper///depot/google3/third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__type_traits/invoke.h?l=147&ws=eaeltsin/6692&snapshot=611):25
#1 0x7f5736d7521a in __thread_execute<std::__u::unique_ptr<std::__u::__thread_struct, std::__u::default_delete<std::__u::__thread_struct> >, void (std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h:130](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h?l=130&ws=eaeltsin/6692&snapshot=611):7), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context> >::*)(), std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h:130](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h?l=130&ws=eaeltsin/6692&snapshot=611):7), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context> > *, 2UL> [third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__thread/thread.h:200](https://cs.corp.google.com/piper///depot/google3/third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__thread/thread.h?l=200&ws=eaeltsin/6692&snapshot=611):3
#2 0x7f5736d7521a in void* std::__u::__thread_proxy<std::__u::tuple<std::__u::unique_ptr<std::__u::__thread_struct, std::__u::default_delete<std::__u::__thread_struct>>, void (std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>>::*)(), std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>>*>>(void*) [third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__thread/thread.h:209](https://cs.corp.google.com/piper///depot/google3/third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__thread/thread.h?l=209&ws=eaeltsin/6692&snapshot=611):3
#3 0x55a92182aef0 in asan_thread_start(void*) [third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp?l=239&ws=eaeltsin/6692&snapshot=611):28
#4 0x7f5726b477da in start_thread (/usr/grte/v5/lib64/libpthread.so.0+0xb7da) (BuildId: b431ea3122d3e21a60bfe317db5010e3)
0x7c72c1ac8c40 is located 0 bytes inside of 296-byte region [0x7c72c1ac8c40,0x7c72c1ac8d68)
freed by thread T48 (task:foo.cpp) here:
#0 0x55a921868842 in operator delete(void*, unsigned long) [third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:155](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp?l=155&ws=eaeltsin/6692&snapshot=611):3
#1 0x7f5736d74a37 in std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>>::~__async_assoc_state() third_party/crosstool/v18/llvm_unstable/src/libcxx/include/future:837:7
#2 0x7f5736d74ab9 in __on_zero_shared third_party/crosstool/v18/llvm_unstable/src/libcxx/include/future:616:3
#3 0x7f5736d74ab9 in std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>>::__on_zero_shared() third_party/crosstool/v18/llvm_unstable/src/libcxx/include/future:870:9
#4 0x7f5736d37029 in __release_shared [third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__memory/shared_count.h:92](https://cs.corp.google.com/piper///depot/google3/third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__memory/shared_count.h?l=92&ws=eaeltsin/6692&snapshot=611):7
#5 0x7f5736d37029 in ~future third_party/crosstool/v18/llvm_unstable/src/libcxx/include/future:987:15
#6 0x7f5736d37029 in ~SpeculativeFuzzyFind [third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.h:269](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.h?l=269&ws=eaeltsin/6692&snapshot=611):8
#7 0x7f5736d37029 in std::__u::__optional_destruct_base<clang::clangd::SpeculativeFuzzyFind, false>::~__optional_destruct_base() third_party/crosstool/v18/llvm_unstable/src/libcxx/include/optional:300:15
#8 0x7f5736d36967 in operator() [third_party/llvm/llvm-project/clang-tools-extra/clangd/ClangdServer.cpp:475](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/ClangdServer.cpp?l=475&ws=eaeltsin/6692&snapshot=611):3
#9 0x7f5736d36967 in void llvm::detail::UniqueFunctionBase<void, llvm::Expected<clang::clangd::InputsAndPreamble>>::CallImpl<clang::clangd::ClangdServer::codeComplete(llvm::StringRef, clang::clangd::Position, clang::clangd::CodeCompleteOptions const&, llvm::unique_function<void (llvm::Expected<clang::clangd::CodeCompleteResult>)>)::$_0>(void*, llvm::Expected<clang::clangd::InputsAndPreamble>&) [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:222](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=222&ws=eaeltsin/6692&snapshot=611):12
#10 0x7f57370b022c in operator() [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:387](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=387&ws=eaeltsin/6692&snapshot=611):12
#11 0x7f57370b022c in operator() [third_party/llvm/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1811](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp?l=1811&ws=eaeltsin/6692&snapshot=611):5
#12 0x7f57370b022c in void llvm::detail::UniqueFunctionBase<void>::CallImpl<clang::clangd::TUScheduler::runWithPreamble(llvm::StringRef, llvm::StringRef, clang::clangd::TUScheduler::PreambleConsistency, llvm::unique_function<void (llvm::Expected<clang::clangd::InputsAndPreamble>)>)::$_0>(void*) [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:222](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=222&ws=eaeltsin/6692&snapshot=611):12
#13 0x7f5722f1eeaf in operator() [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:387](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=387&ws=eaeltsin/6692&snapshot=611):12
#14 0x7f5722f1eeaf in operator() [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:101](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=101&ws=eaeltsin/6692&snapshot=611):5
#15 0x7f5722f1eeaf in operator()<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15) &> [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:45](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=45&ws=eaeltsin/6692&snapshot=611):11
#16 0x7f5722f1eeaf in __invoke<(lambda at [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:44](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=44&ws=eaeltsin/6692&snapshot=611):9), (lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15) &> [third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__type_traits/invoke.h:179](https://cs.corp.google.com/piper///depot/google3/third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__type_traits/invoke.h?l=179&ws=eaeltsin/6692&snapshot=611):25
#17 0x7f5722f1eeaf in __apply_tuple_impl<(lambda at [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:44](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=44&ws=eaeltsin/6692&snapshot=611):9), std::__u::tuple<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> &, 0UL> third_party/crosstool/v18/llvm_unstable/src/libcxx/include/tuple:1380:5
#18 0x7f5722f1eeaf in apply<(lambda at [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:44](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=44&ws=eaeltsin/6692&snapshot=611):9), std::__u::tuple<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> &> third_party/crosstool/v18/llvm_unstable/src/libcxx/include/tuple:1384:5
#19 0x7f5722f1eeaf in GenericThreadProxy<std::__u::tuple<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> > [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:43](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=43&ws=eaeltsin/6692&snapshot=611):5
#20 0x7f5722f1eeaf in void* llvm::thread::ThreadProxy<std::__u::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>>(void*) [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:57](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=57&ws=eaeltsin/6692&snapshot=611):5
#21 0x55a92182aef0 in asan_thread_start(void*) [third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp?l=239&ws=eaeltsin/6692&snapshot=611):28
#22 0x7f5726b477da in start_thread (/usr/grte/v5/lib64/libpthread.so.0+0xb7da) (BuildId: b431ea3122d3e21a60bfe317db5010e3)
previously allocated by thread T48 (task:foo.cpp) here:
#0 0x55a921867bbd in operator new(unsigned long) [third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:86](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp?l=86&ws=eaeltsin/6692&snapshot=611):3
#1 0x7f5736d7441e in std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> std::__u::__make_async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>>(std::__u::__async_func<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>&&) third_party/crosstool/v18/llvm_unstable/src/libcxx/include/future:1833:7
#2 0x7f5736d7408e in std::__u::future<std::__u::__invoke_result<__decay(std::__u::pair<bool, clang::clangd::SymbolSlab>), __decay(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>), __decay(clang::clangd::Context)>::type> std::__u::async<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>(std::__u::launch, std::__u::pair<bool, clang::clangd::SymbolSlab>&&, llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context&&) third_party/crosstool/v18/llvm_unstable/src/libcxx/include/future:1878:14
#3 0x7f5736d52c60 in runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab> > [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h:128](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h?l=128&ws=eaeltsin/6692&snapshot=611):10
#4 0x7f5736d52c60 in startAsyncFuzzyFind [third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:1515](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp?l=1515&ws=eaeltsin/6692&snapshot=611):10
#5 0x7f5736d52c60 in run [third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:1657](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp?l=1657&ws=eaeltsin/6692&snapshot=611):31
#6 0x7f5736d52c60 in clang::clangd::codeComplete(llvm::StringRef, clang::clangd::Position, clang::clangd::PreambleData const*, clang::clangd::ParseInputs const&, clang::clangd::CodeCompleteOptions, clang::clangd::SpeculativeFuzzyFind*) [third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:2304](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp?l=2304&ws=eaeltsin/6692&snapshot=611):32
#7 0x7f5736d365ca in operator() [third_party/llvm/llvm-project/clang-tools-extra/clangd/ClangdServer.cpp:460](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/ClangdServer.cpp?l=460&ws=eaeltsin/6692&snapshot=611):33
#8 0x7f5736d365ca in void llvm::detail::UniqueFunctionBase<void, llvm::Expected<clang::clangd::InputsAndPreamble>>::CallImpl<clang::clangd::ClangdServer::codeComplete(llvm::StringRef, clang::clangd::Position, clang::clangd::CodeCompleteOptions const&, llvm::unique_function<void (llvm::Expected<clang::clangd::CodeCompleteResult>)>)::$_0>(void*, llvm::Expected<clang::clangd::InputsAndPreamble>&) [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:222](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=222&ws=eaeltsin/6692&snapshot=611):12
#9 0x7f57370b022c in operator() [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:387](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=387&ws=eaeltsin/6692&snapshot=611):12
#10 0x7f57370b022c in operator() [third_party/llvm/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1811](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp?l=1811&ws=eaeltsin/6692&snapshot=611):5
#11 0x7f57370b022c in void llvm::detail::UniqueFunctionBase<void>::CallImpl<clang::clangd::TUScheduler::runWithPreamble(llvm::StringRef, llvm::StringRef, clang::clangd::TUScheduler::PreambleConsistency, llvm::unique_function<void (llvm::Expected<clang::clangd::InputsAndPreamble>)>)::$_0>(void*) [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:222](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=222&ws=eaeltsin/6692&snapshot=611):12
#12 0x7f5722f1eeaf in operator() [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:387](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=387&ws=eaeltsin/6692&snapshot=611):12
#13 0x7f5722f1eeaf in operator() [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:101](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=101&ws=eaeltsin/6692&snapshot=611):5
#14 0x7f5722f1eeaf in operator()<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15) &> [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:45](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=45&ws=eaeltsin/6692&snapshot=611):11
#15 0x7f5722f1eeaf in __invoke<(lambda at [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:44](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=44&ws=eaeltsin/6692&snapshot=611):9), (lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15) &> [third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__type_traits/invoke.h:179](https://cs.corp.google.com/piper///depot/google3/third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__type_traits/invoke.h?l=179&ws=eaeltsin/6692&snapshot=611):25
#16 0x7f5722f1eeaf in __apply_tuple_impl<(lambda at [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:44](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=44&ws=eaeltsin/6692&snapshot=611):9), std::__u::tuple<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> &, 0UL> third_party/crosstool/v18/llvm_unstable/src/libcxx/include/tuple:1380:5
#17 0x7f5722f1eeaf in apply<(lambda at [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:44](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=44&ws=eaeltsin/6692&snapshot=611):9), std::__u::tuple<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> &> third_party/crosstool/v18/llvm_unstable/src/libcxx/include/tuple:1384:5
#18 0x7f5722f1eeaf in GenericThreadProxy<std::__u::tuple<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> > [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:43](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=43&ws=eaeltsin/6692&snapshot=611):5
#19 0x7f5722f1eeaf in void* llvm::thread::ThreadProxy<std::__u::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>>(void*) [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:57](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=57&ws=eaeltsin/6692&snapshot=611):5
#20 0x55a92182aef0 in asan_thread_start(void*) [third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp?l=239&ws=eaeltsin/6692&snapshot=611):28
#21 0x7f5726b477da in start_thread (/usr/grte/v5/lib64/libpthread.so.0+0xb7da) (BuildId: b431ea3122d3e21a60bfe317db5010e3)
Thread T49 created by T48 (task:foo.cpp) here:
#0 0x55a921811821 in pthread_create [third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:250](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp?l=250&ws=eaeltsin/6692&snapshot=611):3
#1 0x7f5736d7451b in __libcpp_thread_create [third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__thread/support/pthread.h:182](https://cs.corp.google.com/piper///depot/google3/third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__thread/support/pthread.h?l=182&ws=eaeltsin/6692&snapshot=611):10
#2 0x7f5736d7451b in thread<void (std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h:130](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h?l=130&ws=eaeltsin/6692&snapshot=611):7), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context> >::*)(), std::__u::__async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h:130](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h?l=130&ws=eaeltsin/6692&snapshot=611):7), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context> > *, 0> [third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__thread/thread.h:219](https://cs.corp.google.com/piper///depot/google3/third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__thread/thread.h?l=219&ws=eaeltsin/6692&snapshot=611):14
#3 0x7f5736d7451b in std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> std::__u::__make_async_assoc_state<std::__u::pair<bool, clang::clangd::SymbolSlab>, std::__u::__async_func<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>>(std::__u::__async_func<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>&&) third_party/crosstool/v18/llvm_unstable/src/libcxx/include/future:1834:3
#4 0x7f5736d7408e in std::__u::future<std::__u::__invoke_result<__decay(std::__u::pair<bool, clang::clangd::SymbolSlab>), __decay(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>), __decay(clang::clangd::Context)>::type> std::__u::async<std::__u::future<std::__u::pair<bool, clang::clangd::SymbolSlab>> clang::clangd::runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab>>(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>)::'lambda'(llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context), llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>, clang::clangd::Context>(std::__u::launch, std::__u::pair<bool, clang::clangd::SymbolSlab>&&, llvm::unique_function<std::__u::pair<bool, clang::clangd::SymbolSlab> ()>&&, clang::clangd::Context&&) third_party/crosstool/v18/llvm_unstable/src/libcxx/include/future:1878:14
#5 0x7f5736d52c60 in runAsync<std::__u::pair<bool, clang::clangd::SymbolSlab> > [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h:128](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.h?l=128&ws=eaeltsin/6692&snapshot=611):10
#6 0x7f5736d52c60 in startAsyncFuzzyFind [third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:1515](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp?l=1515&ws=eaeltsin/6692&snapshot=611):10
#7 0x7f5736d52c60 in run [third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:1657](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp?l=1657&ws=eaeltsin/6692&snapshot=611):31
#8 0x7f5736d52c60 in clang::clangd::codeComplete(llvm::StringRef, clang::clangd::Position, clang::clangd::PreambleData const*, clang::clangd::ParseInputs const&, clang::clangd::CodeCompleteOptions, clang::clangd::SpeculativeFuzzyFind*) [third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp:2304](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/CodeComplete.cpp?l=2304&ws=eaeltsin/6692&snapshot=611):32
#9 0x7f5736d365ca in operator() [third_party/llvm/llvm-project/clang-tools-extra/clangd/ClangdServer.cpp:460](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/ClangdServer.cpp?l=460&ws=eaeltsin/6692&snapshot=611):33
#10 0x7f5736d365ca in void llvm::detail::UniqueFunctionBase<void, llvm::Expected<clang::clangd::InputsAndPreamble>>::CallImpl<clang::clangd::ClangdServer::codeComplete(llvm::StringRef, clang::clangd::Position, clang::clangd::CodeCompleteOptions const&, llvm::unique_function<void (llvm::Expected<clang::clangd::CodeCompleteResult>)>)::$_0>(void*, llvm::Expected<clang::clangd::InputsAndPreamble>&) [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:222](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=222&ws=eaeltsin/6692&snapshot=611):12
#11 0x7f57370b022c in operator() [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:387](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=387&ws=eaeltsin/6692&snapshot=611):12
#12 0x7f57370b022c in operator() [third_party/llvm/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1811](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp?l=1811&ws=eaeltsin/6692&snapshot=611):5
#13 0x7f57370b022c in void llvm::detail::UniqueFunctionBase<void>::CallImpl<clang::clangd::TUScheduler::runWithPreamble(llvm::StringRef, llvm::StringRef, clang::clangd::TUScheduler::PreambleConsistency, llvm::unique_function<void (llvm::Expected<clang::clangd::InputsAndPreamble>)>)::$_0>(void*) [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:222](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=222&ws=eaeltsin/6692&snapshot=611):12
#14 0x7f5722f1eeaf in operator() [third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:387](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h?l=387&ws=eaeltsin/6692&snapshot=611):12
#15 0x7f5722f1eeaf in operator() [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:101](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=101&ws=eaeltsin/6692&snapshot=611):5
#16 0x7f5722f1eeaf in operator()<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15) &> [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:45](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=45&ws=eaeltsin/6692&snapshot=611):11
#17 0x7f5722f1eeaf in __invoke<(lambda at [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:44](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=44&ws=eaeltsin/6692&snapshot=611):9), (lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15) &> [third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__type_traits/invoke.h:179](https://cs.corp.google.com/piper///depot/google3/third_party/crosstool/v18/llvm_unstable/src/libcxx/include/__type_traits/invoke.h?l=179&ws=eaeltsin/6692&snapshot=611):25
#18 0x7f5722f1eeaf in __apply_tuple_impl<(lambda at [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:44](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=44&ws=eaeltsin/6692&snapshot=611):9), std::__u::tuple<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> &, 0UL> third_party/crosstool/v18/llvm_unstable/src/libcxx/include/tuple:1380:5
#19 0x7f5722f1eeaf in apply<(lambda at [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:44](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=44&ws=eaeltsin/6692&snapshot=611):9), std::__u::tuple<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> &> third_party/crosstool/v18/llvm_unstable/src/libcxx/include/tuple:1384:5
#20 0x7f5722f1eeaf in GenericThreadProxy<std::__u::tuple<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> > [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:43](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=43&ws=eaeltsin/6692&snapshot=611):5
#21 0x7f5722f1eeaf in void* llvm::thread::ThreadProxy<std::__u::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_1>>(void*) [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:57](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=57&ws=eaeltsin/6692&snapshot=611):5
#22 0x55a92182aef0 in asan_thread_start(void*) [third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp?l=239&ws=eaeltsin/6692&snapshot=611):28
#23 0x7f5726b477da in start_thread (/usr/grte/v5/lib64/libpthread.so.0+0xb7da) (BuildId: b431ea3122d3e21a60bfe317db5010e3)
Thread T48 (task:foo.cpp) created by T0 here:
#0 0x55a921811821 in pthread_create [third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:250](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp?l=250&ws=eaeltsin/6692&snapshot=611):3
#1 0x7f5313cd007a in llvm::llvm_execute_on_thread_impl(void* (*)(void*), void*, std::__u::optional<unsigned int>) third_party/llvm/llvm-project/llvm/lib/Support/Unix/Threading.inc:96:17
#2 0x7f5722f1e97b in thread<(lambda at [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:98](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=98&ws=eaeltsin/6692&snapshot=611):15)> [third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h:133](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/Support/thread.h?l=133&ws=eaeltsin/6692&snapshot=611):12
#3 0x7f5722f1e97b in clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>) [third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp:107](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/support/Threading.cpp?l=107&ws=eaeltsin/6692&snapshot=611):16
#4 0x7f573709a752 in clang::clangd::TUScheduler::runWithPreamble(llvm::StringRef, llvm::StringRef, clang::clangd::TUScheduler::PreambleConsistency, llvm::unique_function<void (llvm::Expected<clang::clangd::InputsAndPreamble>)>) [third_party/llvm/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1814](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp?l=1814&ws=eaeltsin/6692&snapshot=611):18
#5 0x7f5736d1c29b in clang::clangd::ClangdServer::codeComplete(llvm::StringRef, clang::clangd::Position, clang::clangd::CodeCompleteOptions const&, llvm::unique_function<void (llvm::Expected<clang::clangd::CodeCompleteResult>)>) [third_party/llvm/llvm-project/clang-tools-extra/clangd/ClangdServer.cpp:478](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/ClangdServer.cpp?l=478&ws=eaeltsin/6692&snapshot=611):18
#6 0x7f573a3dd4c5 in clang::clangd::runCodeComplete(clang::clangd::ClangdServer&, llvm::StringRef, clang::clangd::Position, clang::clangd::CodeCompleteOptions) [third_party/llvm/llvm-project/clang-tools-extra/clangd/unittests/SyncAPI.cpp:75](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/unittests/SyncAPI.cpp?l=75&ws=eaeltsin/6692&snapshot=611):10
#7 0x7f573c00ea8e in clang::clangd::(anonymous namespace)::CompletionTest_EnableSpeculativeIndexRequest_Test::TestBody()::$_0::operator()(llvm::StringRef) const [third_party/llvm/llvm-project/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:2934](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp?l=2934&ws=eaeltsin/6692&snapshot=611):25
#8 0x7f573c00e0f0 in clang::clangd::(anonymous namespace)::CompletionTest_EnableSpeculativeIndexRequest_Test::TestBody() [third_party/llvm/llvm-project/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:2949](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp?l=2949&ws=eaeltsin/6692&snapshot=611):3
#9 0x7f53145ac861 in HandleExceptionsInMethodIfSupported<testing::Test, void> third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc
#10 0x7f53145ac861 in testing::Test::Run() [third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc:2687](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc?l=2687&ws=eaeltsin/6692&snapshot=611):5
#11 0x7f53145ae92c in testing::TestInfo::Run() [third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc:2836](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc?l=2836&ws=eaeltsin/6692&snapshot=611):11
#12 0x7f53145b01e0 in testing::TestSuite::Run() [third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc:3015](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc?l=3015&ws=eaeltsin/6692&snapshot=611):30
#13 0x7f53145cc9cf in testing::internal::UnitTestImpl::RunAllTests() [third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc:5920](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc?l=5920&ws=eaeltsin/6692&snapshot=611):44
#14 0x7f53145cc23d in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc
#15 0x7f53145cc01d in testing::UnitTest::Run() [third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc:5484](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/third-party/unittest/googletest/src/gtest.cc?l=5484&ws=eaeltsin/6692&snapshot=611):10
#16 0x7f531522374b in RUN_ALL_TESTS [third_party/llvm/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:2317](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h?l=2317&ws=eaeltsin/6692&snapshot=611):73
#17 0x7f531522374b in main [third_party/llvm/llvm-project/third-party/unittest/UnitTestMain/TestMain.cpp:75](https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/third-party/unittest/UnitTestMain/TestMain.cpp?l=75&ws=eaeltsin/6692&snapshot=611):10
#18 0x7f535c9f73d3 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x613d3) (BuildId: 9a996398ce14a94560b0c642eb4f6e94)
#19 0x55a92178c929 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120 |
We started seeing some use-after-frees starting with llvm#125433. This patch ensures we explicitly block for the async task, if there's one, before destructing std::future, independent of the stdlib implementation.
We started seeing some use-after-frees starting with #125433. This patch ensures we explicitly block for the async task, if there's one, before destructing `std::future`, independent of the stdlib implementation.
…077) We started seeing some use-after-frees starting with llvm/llvm-project#125433. This patch ensures we explicitly block for the async task, if there's one, before destructing `std::future`, independent of the stdlib implementation.
There are other instances to the problem like the one kadircet described in clangd. Sjould we consider reverting the patch ? |
hi @philnik777, I guess we're aligned on this being a regression until it's fixed forward and it has been ~2 weeks without it. WDYT about reverting this change and landing it with a fix going forward to minimize the bad commit range ? |
@kadircet Yeah, feel free to revert. |
@kadircet Let's be careful to re-open any closed bugs when a patch is reverted like this :) Otherwise the bug will be forgotten! |
We started seeing some use-after-frees starting with llvm#125433. This patch ensures we explicitly block for the async task, if there's one, before destructing `std::future`, independent of the stdlib implementation.
If the creation of a thread fails, this causes an idle loop that will never end because the thread wasn't started in the first place.
Fixes #125428