Skip to content

EntrySerialize on StateProperty results in StackOverflow - #1602

Draft
juzo1306 wants to merge 2 commits into
devfrom
fix/stack-overflow-on-entry-serialize
Draft

juzo1306 wants to merge 2 commits into
devfrom
fix/stack-overflow-on-entry-serialize

Conversation

@juzo1306

Copy link
Copy Markdown

Problem: The following code in a resource results in a stack overflow, if I open such a resource in the resource UI.

[EntrySerialize]
internal MyOwnStateBase State { get; private set; }
Even though, that could be 'fixed' by

[EntrySerialize]
public string StateAsString => State.ToString();

this should be handled in some way, so that users don't have to spend time on figuring out the root cause of why the application suddenly crashes.

Solution:
added a condition to exclude a self reference to avoid the stackoverflow on the Descriptor property in Resource while using EntrySerialize

…low on the Descriptor property in Resource while using EntrySerialize
@juzo1306 juzo1306 self-assigned this Nov 10, 2026
@juzo1306 juzo1306 added the bug Something isn't working label Nov 10, 2026
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.29%. Comparing base (16cf03d) to head (18837bb).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1602      +/-   ##
==========================================
- Coverage   56.33%   56.29%   -0.04%     
==========================================
  Files         951      951              
  Lines       35835    35835              
  Branches     3519     3519              
==========================================
- Hits        20186    20173      -13     
- Misses      14657    14673      +16     
+ Partials      992      989       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…eated a derived class whose base has self referencing property . This is the pattern which causes the stack overflow. Now only the Moryx is referenced in the Moryx.Tests which is intentional.

@dbeuchler dbeuchler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adjusting the tests. This is good now. I focussed now on the change.

I will link the issue which should presumably be accomplished with that.: #1423

Your change identifies that when SelfReferencingDerived inherits from SelfReferencingBase, the Self property (type SelfReferencingBase) doesnt match SelfReferencingDerived - but it's still a self-reference.

IsAssignableFrom catches this inheritance case not the instance. If ClassA has a property of type ClassB, and ClassB has a property of type ClassA, this will still stack overflow. It is also over-filtering legitimate properties and will skip any property whose type is an ancestor of the instance. For example, if a class has a property of type object that would be skipped because typeof(object).IsAssignableFrom(anyType) is always true.

Another real sample which is broken now. Any config property typed as ConfigBase, UpdatableEntry, IConfig, IUpdatableConfig, or even object would be silently dropped.

public class MyModuleConfig : ConfigBase                                                                                                                                                                                                                                                                          
{                                                                                                                                                                                                                                                                                                                 
      public ConfigBase SomeSubConfig { get; set; }                                                                                                                                                                                                                                                                 
}   

I also talked with @1nf0rmagician about that topic and I/we think there could only be one solution: There must be some kind of cycle detection at the value level e.g., maintaining a HashSet (by reference) of already-visited instances during recursive encoding, and skipping when re-encountering an already-visited object. As far as I know this match how most serializers (Newtonsoft, System.Text.Json) handle this

@dbeuchler
dbeuchler marked this pull request as draft November 11, 2026 06:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants