Skip to content
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

[CUDA] Fix a misuse of std::move: address of stack memory associated with temporary object of type std::lock_guard<std::mutex> returned to caller #3502

Merged
merged 2 commits into from Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions taichi/backends/cuda/cuda_context.h
Expand Up @@ -95,8 +95,8 @@ class CUDAContext {
return ContextGuard(this);
}

std::lock_guard<std::mutex> &&get_lock_guard() {
return std::move(std::lock_guard<std::mutex>(lock_));
std::unique_lock<std::mutex> get_lock_guard() {
return std::unique_lock<std::mutex>(lock_);
}

static CUDAContext &get_instance();
Expand Down
3 changes: 1 addition & 2 deletions taichi/backends/cuda/jit_cuda.cpp
Expand Up @@ -20,8 +20,7 @@ JITModule *JITSessionCUDA ::add_module(std::unique_ptr<llvm::Module> M,
TI_TRACE("PTX size: {:.2f}KB", ptx.size() / 1024.0);
auto t = Time::get_time();
TI_TRACE("Loading module...");
[[maybe_unused]] auto &&_ =
std::move(CUDAContext::get_instance().get_lock_guard());
[[maybe_unused]] auto _ = CUDAContext::get_instance().get_lock_guard();

constexpr int max_num_options = 8;
int num_options = 0;
Expand Down