Skip to content

Conversation

@MBkkt
Copy link
Contributor

@MBkkt MBkkt commented Jun 11, 2025

Produced by this ABSL_UNLOCK_FUNCTION(lock_) for thread analysis noone called Lock, so it thinks unlock called without lock

#ifndef SWIG
  // Documented in the .cc file.
  void UnlockAndSignal() ABSL_UNLOCK_FUNCTION(lock_)
      ABSL_UNLOCK_FUNCTION(update_state_->wait_mutex);
#endif

Produced by this ABSL_UNLOCK_FUNCTION(lock_)

#ifndef SWIG
  // Documented in the .cc file.
  void UnlockAndSignal() ABSL_UNLOCK_FUNCTION(lock_)
      ABSL_UNLOCK_FUNCTION(update_state_->wait_mutex);
#endif
@jmr jmr merged commit 0fe5de5 into google:master Jun 11, 2025
10 checks passed
}

inline bool IsHeld() const {
inline bool IsHeld() const ABSL_ASSERT_EXCLUSIVE_LOCK() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look at this closely enough.

ABSL_ASSERT_EXCLUSIVE_LOCK is for a function that assert()s / terminates.

https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#assert-capability-and-assert-shared-capability

Can you remove ABSL_ASSERT_EXCLUSIVE_LOCK() for now or make an AssertHeld() function and use that?

https://github.com/abseil/abseil-cpp/blob/9ac131cf7da4de8b19b4c956a0c13edba74d92d9/absl/base/internal/spinlock.h#L129

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertHeld() asserts in opt mode as well as dbg, so just remove ABSL_ASSERT_EXCLUSIVE_LOCK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#437

Made PR to remove incorrect annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About assertheld I'm not sure, because usecase in s2 different:
ABSL_DCHECK(cells_lock_.IsHeld());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway it compiles without any declaration for IsHeld() so it's probably ok to keep it like this for now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants