Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ref(logs): more Debug.Assert
  • Loading branch information
Flash0ver committed Aug 10, 2025
commit 3608899f32e20743dff2abcb1ed1be39048461ff
3 changes: 3 additions & 0 deletions src/Sentry/Threading/ScopedCountdownLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ internal CounterScope TryEnterCounterScope()

private void ExitCounterScope()
{
Debug.Assert(_event.CurrentCount >= 1);
_ = _event.Signal();
}

Expand All @@ -75,6 +76,7 @@ internal LockScope TryEnterLockScope()
{
if (Interlocked.CompareExchange(ref _isEngaged, 1, 0) == 0)
{
Debug.Assert(_event.CurrentCount >= 1);
_ = _event.Signal(); // decrement the initial count of 1, so that the event can be set with the count reaching 0 when all entered 'CounterScope' instances have exited
return new LockScope(this);
}
Expand All @@ -84,6 +86,7 @@ internal LockScope TryEnterLockScope()

private void ExitLockScope()
{
Debug.Assert(_event.IsSet);
_event.Reset(); // reset the signaled event to the initial count of 1, so that new 'CounterScope' instances can be entered again
Copy link
Member Author

@Flash0ver Flash0ver Aug 11, 2025

Choose a reason for hiding this comment

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

note: fix

fixed by performing the "Reset before CompareExchange" when existing in the reverse order than the "CompareExchange before Signal" when entering


if (Interlocked.CompareExchange(ref _isEngaged, 0, 1) != 1)
Expand Down