intel / intel/llvm

[Coverity][UR] Potential double-unlock of a mutex in the L0 adapter

Open
#20,726 0 comments 0 reactions 1 assignee Claimed by @nrspruit View on GitHub
bug Coverity level-zero unified-runtime
Dominant language
LLVM
Stars
1.5k
Forks
854
Avg merge
3d 17h
Merged PRs (30d)
137

Description

Reported by Coverity as CID `520793`, you can access Coverity results here: https://scan.coverity.com/projects/intel-llvm?tab=overview

The following piece of code:

https://github.com/intel/llvm/blob/faa61805224a993f8f9de6214ba0678afc9e53e4/unified-runtime/source/adapters/level_zero/event.cpp#L1585-L1588

Is located within a loop:

https://github.com/intel/llvm/blob/faa61805224a993f8f9de6214ba0678afc9e53e4/unified-runtime/source/adapters/level_zero/event.cpp#L1552-L1553

Meaning, that we may call `CurQueue->Mutex.unlock();` multiple times. That mutex is a [`std::shared_mutex`](https://en.cppreference.com/w/cpp/thread/shared_mutex.html) whose [`unlock`](https://en.cppreference.com/w/cpp/thread/shared_mutex/unlock.html) method behavior is undefined if a mutex is already unlocked.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.