Comments (6)
Yes, I think your fix is appropriate. I do have to double-check some related semantics and make sure.
On a side note, the .NET Core version of AsyncEx primitives do always use asynchronous continuations.
from asyncex.
Hi! Is there an update on this? I am having that issue I believe (and the same StackOverflow with stack trace from windbg). Or perhaps a work-around? Sorry, I couldn't quite figure it out from the linked SO post.
from asyncex.
@fry: The new version of the async coordination primitives is available in a prerelease version.
There have been some (minor) API changes, but most upgrades should go quite smoothly.
from asyncex.
I ran into this in my codebase a few times. I haven't switched to the new API yet but will do so in a few weeks when I can have things broken for a few days (testing for this sort of thing is hard as it is tricky to reproduce).
In my code I had a whole bunch of repositories wait on a single shared async lock on startup - it was to allow initialisation to happen exactly once (but not too soon). Those repositories could have 100 or so clients waiting to make their first request. Rather than have so many waiters on the one async lock, I added another async lock and a flag to each repository so the queue of waiters was spread amongst more locks. That solved the problem for me.
It was one of those weird things though where I quite happily had N repositories with M initial requests each, but as soon as I bumped M up by a few and then added my N+1th repository I consistently got stack overflows.
At one stage I experimented with awaiting Task.Yield() too. I'm not entirely sure that helped as I'm not familiar enough with the internals of how that might interact with the call stack and continuations.
Note that I'm not really making any use of ConfigureAwait() anywhere. That might have an effect too as far as call stack depth is concerned.
from asyncex.
I am having similar trouble running 3.0.1. I have the following wrapper class around AsyncMonitor
public class EasyAsyncMonitor
{
private AsyncMonitor _monitor = new AsyncMonitor();
public Task WaitAsync(CancellationToken token = default(CancellationToken))
{
return EnterMonitorAndDo(() =>
{
return _monitor.WaitAsync();
}, token);
}
public Task Pulse(CancellationToken token = default(CancellationToken))
{
return EnterMonitorAndDo(() =>
{
_monitor.Pulse();
}, token);
}
public Task PulseAll(CancellationToken token = default(CancellationToken))
{
return EnterMonitorAndDo(() =>
{
_monitor.PulseAll();
}, token);
}
private async Task EnterMonitorAndDo(Func<Task> doThis, CancellationToken token)
{
using(await _monitor.EnterAsync(token))
{
await doThis().DetachContext(); //Overflow occurs here
}
}
private async Task EnterMonitorAndDo(Action doThis, CancellationToken token)
{
using(await _monitor.EnterAsync(token))
{
doThis();
}
}
}
And DetachContext is defined as
public static ConfiguredTaskAwaitable DetachContext(this Task t)
{
return t.ConfigureAwait(false);
}
Occasionally I will get a stackoverflow exception thrown from the line indicated above with the comment. The stack trace is unavailable but is visible in Visual studio debugging. It is full of that single line and then [Resuming Async Method] and [External code] entries between them.
Could this be related or is it incorrect usage of the Monitor?
from asyncex.
Should be fixed in 4.0.0-pre
.
from asyncex.
Related Issues (20)
- Support AsyncProducerConsumerQueue wait for empty
- AsyncCollection IsEmpty HOT 3
- [Discussion] Return `ValueTask` instead of `AwaitableDisposable`? HOT 5
- [Question] .WaitAndUnwrapException() vs AsyncContext and potential deadlock HOT 2
- The collection has been marked as complete with regards to additions HOT 1
- Atomic wait semantics lead to continued processing after cancellation HOT 3
- What happened to NotifyTask? HOT 1
- CancellationTokenTaskSource's dispose
- Using LazyAsync with JSONSeralizer? HOT 1
- Producer/Consumer PriorityQueue
- doc/TaskConstants.md links to an article that doesn't exist anymore
- Cross thread Sync context stealing HOT 2
- [Question] Using discard with AsyncLock HOT 1
- [Question] Is ConfigureAwait(false) is needed? HOT 1
- AsyncContext holds exceptions until all tasks complete.
- Feature request: AsyncReaderWriterLock support for UpgradeableReadLock HOT 11
- The ApmAsyncFactory interop hangs if a path in async method returns synchronously. HOT 1
- Setting AsyncAutoResetEvent after used in Task.WhenAny HOT 3
- AsyncLazy with API call is being called twice across 4 components. HOT 2
- Strong names HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asyncex.