YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

Fix infinite recursion of the hash code function of YamlMappingNode

Open tomer-amir opened this issue 1 year ago • 1 comments

I have an issue where the hash code function enters infinite recursion in some cases with circular references. This is a suggestion to fix the issue, as I noticed that the start position seems unique, so that can be relied on, and this does not require any recursion.

Please tell me if you think that there is a better fix, but this worked for me when I tested it.

Here is an example that causes infinite recursion:

? !Key
    properties:
            properties:
                rowID: &id1 !Key
                        rowID: *id1
: *id2

I am not sure what exactly causes the issue here, this is a filtered snippet from a YAML I was trying to parse and I got the issue with, so it might not be exactly valid, but it reproduces the issue and verifies the fix.

tomer-amir avatar May 28 '23 12:05 tomer-amir

We need some tests for the fix to make sure we don't accidentally break it in the future. If you can add those we can look at merging it in.

EdwardCooke avatar Jun 17 '23 14:06 EdwardCooke

We need some tests for the fix to make sure we don't accidentally break it in the future. If you can add those we can look at merging it in.

Hi, I added some test cases that work only after the fix. we would appreciate it if you'll take another look and merge it 🙏🏽

barapiiro avatar May 28 '24 12:05 barapiiro

This feature has been released in version 15.1.6.

aaubry avatar May 29 '24 15:05 aaubry