question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Semaphore cannot be released in AdalAuthenticator

See original GitHub issue

Version

4.4.3

Describe the bug

The bot is running SDK Microsoft.Bot.Builder 4.4.3 in a Linux docker env of base image dotnet:2.1-runtime.

We see the semaphore error SemaphoreFullException with error message “Adding the specified count to the semaphore would cause it to exceed its maximum count”, which suggests semaphore is released more than acquired. From the code in AdalAuthenticator.fs, we do not see the reason how it can happen. Moreover we pulled the botbuilder source code into our application and added some logging around the AdalAuthenticator code to do a test. When the issue happened, semaphore was acquired successfully by waitOne() and when Release() function was called the first time after acquired, it failed and went to retry.

The issue happened mostly after a production deployment. We guess it’s because of a spike of the traffic. However, we could not reliably reproduce the issue.

We also tried to replace Semaphore with SemaphoreSlim since the later doesn’t use system calls, which might be the issue. After we used SemaphoreSlim, we cannot reproduce the issue anymore but it doesn’t mean it’s fixed since we could not reliably reproduce the issue before as I said.

I’d like to get some thoughts from community or anyone else has experienced the same issue. Should we change it to SemaphoreSlim since it is supposed to be more suitable for the use case? I know @carlosscastro has made a lot of testings when submitted the PR https://github.com/microsoft/botbuilder-dotnet/pull/1299. Do you have any suggestions on this? Thanks

[bug]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
carlosscastrocommented, Aug 8, 2019

Thanks for reporting this @chaoteng, and for the thorough description! Let me take a look and analyze under which conditions this might happen.

0reactions
cleemullinscommented, Sep 12, 2019

This has been released earlier this week as part of the C# 4.5.2 SDK.

Please re-open if the issue persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Binary Semaphore not working if release() comes before ...
Yes, you're writing broken code (at least by your expectations) by releasing (increasing permits) before acquiring. This is perfectly valid, ...
Read more >
SLES15-SP2-SAP-BYOS-Azure.patches.txt
Patch: SUSE-2018-1277 Released: Thu Jul 5 08:38:06 2018 Summary: Security update for unzip ... Add missing baseclass init call for AdalAuthentication.
Read more >
SLES15-SP2-HPC-Azure.patches.txt
Patch: SUSE-2018-1277 Released: Thu Jul 5 08:38:06 2018 Summary: Security update for unzip ... Add missing baseclass init call for AdalAuthentication.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found