Skip to content

7.0.6 Client getting System.AccessViolationException: Attempted to read or write protected memory. #1021

@APahlka

Description

@APahlka

I have a .Net 10 server/client which was updated from 6.1.7 to 7.0.6 and after a few calls to a Unary call that has a shape like:

UnaryResult GetDigitalTypeMappings(int? mapId)

where the mapId is null, I get:

Fatal error.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Grpc.Net.Client.Internal.StreamExtensions+d__91[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Grpc.Net.Client.Internal.StreamExtensions+<WriteMessageAsync>d__91[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Grpc.Net.Client, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad]](d__91<System.__Canon> ByRef) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Grpc.Net.Client.Internal.StreamExtensions+<WriteMessageAsync>d__91[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Grpc.Net.Client, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad]](d__91<System.__Canon> ByRef) at Grpc.Net.Client.Internal.StreamExtensions.WriteMessageAsync[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.IO.Stream, Grpc.Net.Client.Internal.GrpcCall, System.__Canon, System.Action2<System.__Canon,Grpc.Core.SerializationContext>, Grpc.Core.CallOptions)
at Grpc.Net.Client.Internal.GrpcCall2[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].WriteMessageAsync(System.IO.Stream, System.__Canon, Grpc.Core.CallOptions) at Grpc.Net.Client.Internal.GrpcCall2[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].g__WriteAsync|60_0(System.__Canon, System.IO.Stream)
at Grpc.Net.Client.Internal.PushUnaryContent2[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].SerializeToStreamAsync(System.IO.Stream, System.Net.TransportContext) at System.Net.Http.Http2Connection+Http2Stream+<SendRequestBodyAsync>d__45.MoveNext() at System.Net.Http.Http2Connection+Http2Stream.SendRequestBodyAsync(System.Threading.CancellationToken) at System.Net.Http.Http2Connection+<SendAsync>d__111.MoveNext() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Net.Http.Http2Connection+<SendAsync>d__111, System.Net.Http, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action, Boolean) at System.Threading.Tasks.Task.RunContinuations(System.Object) at System.Net.Http.Http2Connection+<SendHeadersAsync>d__97.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Net.Http.Http2Connection+<SendHeadersAsync>d__97, System.Net.Http, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].ExecutionContextCallback(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Net.Http.Http2Connection+<SendHeadersAsync>d__97, System.Net.Http, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext(System.Threading.Thread) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Net.Http.Http2Connection+d__97, System.Net.Http, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
at System.Threading.Tasks.AwaitTaskContinuation.System.Threading.IThreadPoolWorkItem.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()

If the mapId is not null, it does not have the issue. When I put the client back to version 6.1.7, it does not have the error.

For the gRPC nuget packages, I am using Grpc.Net.Client version 2.71.0

I have also tried with the 7.0.8 client and have the same issue.

I also tried using a Framework 4.8 client and I only get this:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at MagicOnion.Internal.GrpcMethodHelper.<>c__DisplayClass8_01.<CreateBoxedMarshaller>b__0(Box1 obj, SerializationContext ctx)
at Grpc.Core.Internal.AsyncCallBase2.UnsafeSerialize(TWrite msg, DefaultSerializationContext context) at Grpc.Core.Internal.AsyncCall2.UnaryCallAsync(TRequest msg)
at Grpc.Core.Calls.AsyncUnaryCall[TRequest,TResponse](CallInvocationDetails2 call, TRequest req) at Grpc.Core.DefaultCallInvoker.AsyncUnaryCall[TRequest,TResponse](Method2 method, String host, CallOptions options, TRequest request)
at MagicOnion.Client.Internal.RawMethodInvoker4.<.ctor>b__2_0(RequestContext context) at MagicOnion.Client.Internal.InterceptInvokeHelper.InvokeWithFilter(RequestContext context) at MagicOnion.Client.Internal.RawMethodInvoker4.d__5.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start[TStateMachine](TStateMachine& stateMachine) at MagicOnion.Client.Internal.RawMethodInvoker4.InvokeUnaryCore(MagicOnionClientBase client, String path, TRequest request, Func2 requestMethod) at MagicOnion.Client.Internal.RawMethodInvoker4.InvokeUnary(MagicOnionClientBase client, String path, TRequest request)
at MagicOnion.DynamicallyGeneratedClient.dataPARC.Store.Service.Interfaces.IConfigurationServiceClient.GetDigitalTypeMappings(Nullable`1 )

Let me know what other information you would like to help troubleshoot this issue. Thank you for any help you can give.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions