grpc-dotnet: RpcException causes "Infinite recursion during resource lookup within System.Private.CoreLib." and terminates process

What version of gRPC and what language are you using?

C# net5.0 Grpc.Net.Client 2.34.0

What operating system (Linux, Windows,…) and version?

Win 10 x64 - 10.0.19041

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

5.0.102

What did you do?

Made an AsyncUnary client call and awaited the response headers and then response, the server immediately writes response headers and then after a short delay intentionally throws an RpcException.

        static async Task Main()
        {
            using var channel = GrpcChannel.ForAddress("http://localhost:5001");
            var client =  new Greeter.GreeterClient(channel);
            var helloCall =  client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" });
            Console.WriteLine(string.Join(", ", await helloCall.ResponseHeadersAsync));
            Console.WriteLine(await helloCall.ResponseAsync);
        }

What did you expect to see?

An RpcException thrown while awaiting response.

What did you see instead?

Response headers are printed and then the process terminates when it should be throwing RpcException.

[Entry: key=date, value=Sat, 06 Feb 2021 06:59:37 GMT], [Entry: key=server, value=Kestrel]
Process terminated. Infinite recursion during resource lookup within System.Private.CoreLib.  This may be a bug in System.Private.CoreLib, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names.  Resource name: Exception_EndOfInnerExceptionStack
   at System.Environment.FailFast(System.String)
   at System.SR.InternalGetResourceString(System.String)
   at System.SR.GetResourceString(System.String, System.String)
   at System.SR.GetResourceString(System.String)
   at System.SR.get_Exception_EndOfInnerExceptionStack()
   at System.Exception.ToString()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at MyProject.Program.<Main>(System.String[])

When running this under Rider it suggests the following: Target process has exited during evaluation of instance method System.Exception.ToString() with actual parameters Grpc.Core.RpcException. This may possibly happen due to StackOverflowException.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (2 by maintainers)

Most upvoted comments

Thank you @jkotas and @tarekgh

I have no watches defined; I have not yet been able to reproduce without a debugger attached but even with Rider debugger attached it has been difficult to reproduce with Greeter example. I will try to reproduce without debugger and in VS, but I think I need to file an issue with Rider.

Both dumps are attached as zips in 5MB chunks to work around GitHub file limit. File extension changed from .00X to .zip to get past extension filter, to make these valid archives again you must delete the last “.zip” in filename.

image

Windows full minidump:

dump.27316.zip.001.zip dump.27316.zip.002.zip dump.27316.zip.003.zip dump.27316.zip.004.zip dump.27316.zip.005.zip dump.27316.zip.006.zip dump.27316.zip.007.zip dump.27316.zip.008.zip

Ubuntu .crash file from /var/crash/ _usr_share_dotnet_dotnet.1000.zip.001.zip _usr_share_dotnet_dotnet.1000.zip.002.zip _usr_share_dotnet_dotnet.1000.zip.003.zip _usr_share_dotnet_dotnet.1000.zip.004.zip _usr_share_dotnet_dotnet.1000.zip.005.zip _usr_share_dotnet_dotnet.1000.zip.006.zip

Edit: Culture is en-US on Windows and en-CA on Ubuntu.