-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix(conf): Memory leak on loading YAML with cyclic dependencies #5189
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
Conversation
Codecov Report
✅ All modified and coverable lines are covered by tests.
📢 Thoughts on this report? Let us know!
bfc5a41
to
0f63f2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Fixes a memory leak and stack overflow issue when loading YAML configurations with cyclic struct references. The problem occurred when structs contained self-referencing fields (like a Node with Children of type []*Node), causing infinite recursion during type analysis.
- Introduces cycle detection mechanism using a visited map to track processed types
- Refactors buildFieldsInfo function to accept and utilize the visited map parameter
- Consolidates buildStructFieldsInfo functionality directly into buildFieldsInfo
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
core/conf/config.go | Implements cycle detection by adding visited map parameter to buildFieldsInfo and related functions, removes buildStructFieldsInfo |
core/conf/config_test.go | Updates test call to include new visited map parameter and adds comprehensive test for cyclic reference handling |
Uh oh!
There was an error while loading. Please reload this page.
I fixes a memory leak issue that occurred when loading a YAML configuration file with self-referencing structs. The previous implementation entered an infinite loop during type analysis, causing a stack overflow.
eg:
Solution:
The fix introduces a robust cycle detection mechanism within the
buildFieldsInfo
function. It now uses avisited
map to keep track of processed types.I also add a test to show whether it works
close #5140