fix(util/gutil): fix false positive cycle detection in Dump (#2902)#4626
Merged
hailaz merged 1 commit intogogf:masterfrom Jan 19, 2026
Merged
fix(util/gutil): fix false positive cycle detection in Dump (#2902)#4626hailaz merged 1 commit intogogf:masterfrom
hailaz merged 1 commit intogogf:masterfrom
Conversation
Change cycle detection from global to path-based approach. Previously, shared references (multiple fields pointing to the same object) were incorrectly marked as cycle dumps. Now only true cycles in the traversal path are detected. - Add defer delete() to remove pointer from set when function returns - Move pointer addition inside the if block - Add test cases for shared pointer and same type fields scenarios
889e23f to
9ab66ca
Compare
hailaz
approved these changes
Jan 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gutil.DumpProblem
When using
gutil.Dumpwith structs containing fields that share the samereflect.Type(e.g., multipleintfields), the second field's type was incorrectly displayed as<cycle dump 0x...>.Example from issue:
Solution
Change cycle detection from global to path-based:
defer delete()to remove pointer from tracking set when function returnsBenchmark Comparison
Run benchmark with:
Before fix (master branch):
After fix (this PR):
Performance impact:
defer delete()operation is O(1), negligible compared to reflection overheadTest plan
gutiltests pass (68 tests)Test_Dump_Issue2902_SharedPointer- shared pointer not marked as cycleTest_Dump_Issue2902_SameTypeFields- original issue scenarioFixes #2902