Skip to content
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

[linux-arm64] Random and rare runtime crash System.ArgumentOutOfRangeException (System.Net.Sockets) #70486

Closed
NQ-Merinos opened this issue Jun 9, 2022 · 6 comments

Comments

@NQ-Merinos
Copy link

Description

Random and rare crashes with this exception:

Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'state')
  at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.InvokeContinuation(Action`1 continuation, Object state, Boolean forceAsync, Boolean requiresExecutionContextFlow)
  at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs _)
  at System.Net.Sockets.SocketAsyncEngine.System.Threading.IThreadPoolWorkItem.Execute()
  at System.Threading.ThreadPoolWorkQueue.Dispatch()
  at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

It seems to append only on loaded applications.

Exit signal: Abort (6)

Reproduction Steps

We don't have any reproduction yet. We probably need to heavily stress network! It seems to be a race condition.

Expected behavior

don't crash the runtime when we are using sockets...

Actual behavior

random and rare crashes of the runtime

Regression?

No response

Known Workarounds

No response

Configuration

Dotnet runtime version: 6.0.5 (70ae3df)
OS : GNU/Linux Debian 11 Bullseye
CPU: ARM64 Graviton 2 (AWS)
We are using Orleans with this application

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 9, 2022
@ghost
Copy link

ghost commented Jun 9, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Random and rare crashes with this exception:

Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'state')
  at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.InvokeContinuation(Action`1 continuation, Object state, Boolean forceAsync, Boolean requiresExecutionContextFlow)
  at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs _)
  at System.Net.Sockets.SocketAsyncEngine.System.Threading.IThreadPoolWorkItem.Execute()
  at System.Threading.ThreadPoolWorkQueue.Dispatch()
  at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

It seems to append only on loaded applications.

Exit signal: Abort (6)

Reproduction Steps

We don't have any reproduction yet. We probably need to heavily stress network! It seems to be a race condition.

Expected behavior

don't crash the runtime when we are using sockets...

Actual behavior

random and rare crashes of the runtime

Regression?

No response

Known Workarounds

No response

Configuration

Dotnet runtime version: 6.0.5 (70ae3df)
OS : GNU/Linux Debian 11 Bullseye
CPU: ARM64 Graviton 2 (AWS)
We are using Orleans with this application

Other information

No response

Author: NQ-Merinos
Assignees: -
Labels:

area-System.Net.Sockets

Milestone: -

@stephentoub
Copy link
Member

Is it possible you're awaiting the same ValueTask instance multiple times, using a ValueTask concurrently, etc. (all of which is considered erroneous usage)? This is most likely coming from:

if (!(state is ValueTaskSourceAsTask vtst) ||
!(vtst._source is IValueTaskSource source))
{
// This could only happen if the IValueTaskSource passed the wrong state
// or if this callback were invoked multiple times such that the state
// was previously nulled out.
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.state);
return;
}

@NQ-Brewir
Copy link

It is possible. I just spotted a point where a ValueTask is not awaited (but still stored in a _ variable). Could it lead to this error?

@stephentoub
Copy link
Member

It is possible. I just spotted a point where a ValueTask is not awaited (but still stored in a _ variable). Could it lead to this error?

It shouldn't. Not consuming a ValueTask can still be problematic if the instance was relying on being returned to a pool as part of it, but it shouldn't lead to this error.

@karelz
Copy link
Member

karelz commented Jun 14, 2022

Triage: We believe this is bug in the user code -- awaiting ValueTask multiple times, most likely concurrently. Closing.
If there is evidence it is not the case, please reopen with additional info and we will take further look. Thanks!

@karelz karelz closed this as completed Jun 14, 2022
@karelz karelz added this to the 7.0.0 milestone Jun 14, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jun 14, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 14, 2022
@karelz
Copy link
Member

karelz commented May 27, 2023

Problem in .NET identified after all - duplicate of #84407

Fixed in 7.0.7 in PR #84641 and in 6.0.18 in PR #84432.
Main (8.0) is not affected - see description in #84432.

@karelz karelz modified the milestones: 7.0.0, 6.0.x May 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants