-
-
Notifications
You must be signed in to change notification settings - Fork 947
System.InvalidOperationException: Renci.SshNet.Abstractions.SocketExtensions+_ConnectAsync_d__1.MoveNext #913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you please provide the exception call stack? |
Call stack for the failure: |
Hm, not very readable... I'll try to do a repro... |
A little more detail might help to reproduce it. The failure would occur after canceling a dialog box that was waiting for a connection to complete. The connection was being made to an address that was not responding so normally would have timed out after 15 seconds. The InvalidOperationException had text to the effect that an attempt was made to Complete a task that was already marked as Completed. |
I am unable to reproduce this error; I tried a console app on net472 and netcoreapp3.1. It could be that the error is due to |
I was able to repro with the attached program. Start the program then hit the OK button on the dialog box when it pops up. |
At first I thought the problem was caused by sync/async used in the repro, but when I added a button to the form with this handler: private async void Button_Click(object sender, RoutedEventArgs e)
{
await AddConnectionAsync();
} the problem persists. |
@paulmaybee can you please test the fix if it solves the problem in your real application? |
@IgorMilavec This fix seems to work. Thanks. |
Great, thanks for feedback. Let me do some more tests in real life and then I'll "un-draft" the PR. |
We are seeing crashes when an async connect operation is canceled. Analyses of the crash leads me to believe that SocketAsyncEventArgsAwaitable.SetCompleted is being called twice: once during the handling of the cancel and once when the IOCompletion fires. However the code that runs the continuationAction does not handle this condition appropriately and runs the continuationAction twice, causing the InvalidOperationException. Changing this line in SetCompleted:
to:
seems to fix the problem.
The text was updated successfully, but these errors were encountered: