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

Orleans 4 to 7-rc2 - Stack overflow exception on GrainFactory.GetGrain call #8047

Closed
NSTA2 opened this issue Oct 21, 2022 · 4 comments · Fixed by #8301
Closed

Orleans 4 to 7-rc2 - Stack overflow exception on GrainFactory.GetGrain call #8047

NSTA2 opened this issue Oct 21, 2022 · 4 comments · Fixed by #8301
Assignees
Labels
Needs: investigation 🔍 Issue that needs investigation Status: Fixed
Milestone

Comments

@NSTA2
Copy link

NSTA2 commented Oct 21, 2022

I have a project which now runs correctly with Orleans 4, but overnight the 7-rc2 was released so I thought I'd try that while I'm in "upgrade mode".

Unfortunately, upgrading the package version to 7-rc2 causes a previously working project to produce this stack overflow when trying to get a grain. The grain class in question has two generic parameters and uses IGrainWithStringKey.

Stack overflow.
   at System.RuntimeType.IsSubclassOf(System.Type)
   at System.Collections.Generic.Dictionary`2[[Orleans.Runtime.GrainInterfaceType, Orleans.Core.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null],[Orleans.GrainInterfaceTypeToGrainTypeResolver+CacheEntry, Orleans.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].FindValue(Orleans.Runtime.GrainInterfaceType)
   at System.Collections.Generic.Dictionary`2[[Orleans.Runtime.GrainInterfaceType, Orleans.Core.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null],[Orleans.GrainInterfaceTypeToGrainTypeResolver+CacheEntry, Orleans.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null]].TryGetValue(Orleans.Runtime.GrainInterfaceType, CacheEntry ByRef)
   at Orleans.GrainInterfaceTypeToGrainTypeResolver.GetGrainType(Orleans.Runtime.GrainInterfaceType)
   at Orleans.GrainInterfaceTypeToGrainTypeResolver.GetGrainType(Orleans.Runtime.GrainInterfaceType)
   at Orleans.GrainInterfaceTypeToGrainTypeResolver.GetGrainType(Orleans.Runtime.GrainInterfaceType)
   at Orleans.GrainInterfaceTypeToGrainTypeResolver.GetGrainType(Orleans.Runtime.GrainInterfaceType)
   at Orleans.GrainInterfaceTypeToGrainTypeResolver.GetGrainType(Orleans.Runtime.GrainInterfaceType)

   ....  lots more of these

   at Orleans.GrainInterfaceTypeToGrainTypeResolver.GetGrainType(Orleans.Runtime.GrainInterfaceType)
   at Orleans.GrainInterfaceTypeToGrainTypeResolver.GetGrainType(Orleans.Runtime.GrainInterfaceType)
   at Orleans.GrainInterfaceTypeToGrainTypeResolver.GetGrainType(Orleans.Runtime.GrainInterfaceType)
   at Orleans.GrainFactory.GetGrain(System.Type, Orleans.Runtime.IdSpan, System.String)
   at Orleans.GrainFactory.GetGrain[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.String, System.String)
   at Orleans.Runtime.InternalClusterClient.GetGrain[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.String, System.String)
@ghost ghost added the Needs: triage 🔍 label Oct 21, 2022
@benjaminpetit
Copy link
Member

Do you have a repro?

@ReubenBond
Copy link
Member

A repro or a memory dump would be very useful here.

@ReubenBond ReubenBond self-assigned this Oct 25, 2022
@ReubenBond ReubenBond added Needs: investigation 🔍 Issue that needs investigation and removed Needs: triage 🔍 labels Oct 25, 2022
@NSTA2
Copy link
Author

NSTA2 commented Oct 26, 2022

This seems to only be repeatable when using VS 2022 (Enterprise) - not with VS Preview. This makes providing reproduction difficult as the unit test I have only fails when running VS2022, which won't compile the main branch due to this issue. Looking at the method in question, it seems reasonable that a stack overflow may occur due to the recursive call at line 128 of GrainInterfaceTypeToGrainTypeResolver.cs - but repeating the condition that leads to that is a challenge at present due to the above. I've given @benjaminpetit access to the repo in question and similarly, the test succeeds for him when running VS Preview. In order to reproduce, he too would need to run the unit test I showed him with VS Enterprise (non-preview).

@ReubenBond
Copy link
Member

It seems that this issue occurs in the following situation:

  • GetGrain<T> call where
  • T is a generic grain interface
  • T has no corresponding grain implementation class
    I'll develop a fix

@ReubenBond ReubenBond added this to the 7.0.1 milestone Dec 2, 2022
@ghost ghost added the Status: Fixed label Feb 1, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: investigation 🔍 Issue that needs investigation Status: Fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants