async/await and the visitor pattern [closed]

孤街浪徒 提交于 2020-04-13 07:04:12

问题


We've recently transformed one of our visitors for an object tree-like structure (that is about 40 levels deep) to the async/await pattern because the innermost accept methods now perform work which uses async/await.

Everything works fine except when an exception is thrown deep in the call graph, then we run into StackOverflowExceptions.

Our current assumption: it looks like exception unwinding is happening on a single thread and we run into StackOverflowExceptions. This would explain the crashdump stack traces which have the exception throw statement on the call stack and then go up and up until we reach a StackOverflowException. (while during the normal flow only the async state machine and the current continuation is on the stack, for which there is enough stack space available)

Is using async/await reducing the possible stack "depth" in a default .NET application on .NET 4.7.2 to something smaller than 100? Is there a good way to overcome this? Is there a recommendation to not write async/await visitors in .NET? Is there another explaination for this behavior?

来源:https://stackoverflow.com/questions/61102165/async-await-and-the-visitor-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!