[libc-commits] [libc] [libc] Return EBUSY from pthread_mutex_destroy on a locked mutex (PR #239986)
via libc-commits
libc-commits at lists.llvm.org
Sat Nov 7 06:47:18 PST 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- libc/src/__support/threads/unix_mutex.h libc/src/pthread/pthread_mutex_destroy.cpp libc/test/integration/src/pthread/pthread_mutex_test.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libc/src/__support/threads/unix_mutex.h b/libc/src/__support/threads/unix_mutex.h
index c330aba5b..59d61b497 100644
--- a/libc/src/__support/threads/unix_mutex.h
+++ b/libc/src/__support/threads/unix_mutex.h
@@ -76,9 +76,8 @@ public:
// glibc says EBUSY and leaves a locked mutex as it was, except a robust
// one, whose owner may have exited. Only recursive and error checking
// mutexes record an owner, so the futex word is what tells a locked one.
- if (!lock->robust &&
- (lock->owner != 0 || lock->lock_count != 0 ||
- lock->futex.load(cpp::MemoryOrder::RELAXED) != 0))
+ if (!lock->robust && (lock->owner != 0 || lock->lock_count != 0 ||
+ lock->futex.load(cpp::MemoryOrder::RELAXED) != 0))
return MutexError::BUSY;
RawMutex::destroy(lock);
return MutexError::NONE;
``````````
</details>
https://github.com/llvm/llvm-project/pull/239986
More information about the libc-commits
mailing list