config_format: fix caller-owned parse failure cleanup#11955
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesCaller-owned cleanup fix and hot-reload improvements
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9ffa6ace9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (cf_created == FLB_TRUE) { | ||
| flb_cf_destroy(cf); | ||
| } |
There was a problem hiding this comment.
Keep a pointer to caller-owned cf on failure
When parsing fails for a caller-owned config, this path now returns NULL without freeing cf, but hot reload still does new_cf = flb_cf_create_from_file(new_cf, file) in src/flb_reload.c:554 and then returns on !new_cf, losing the only pointer to the caller-owned config object. A bad reload config, such as a missing include, will now leak that new_cf and any reconstructed CLI config stored in it on every failed reload attempt; use a temporary return value or update the error path to destroy the original caller-owned object.
Useful? React with 👍 / 👎.
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
e9ffa6a to
2bf4ac4
Compare
Summary
This fixes a config-format ownership bug found while reviewing PR #11939.
When
flb_cf_fluentbit_create()orflb_cf_yaml_create()receives a caller-ownedstruct flb_cf *and parsing fails, the constructor must not destroy that object before returningNULL.The constructors now only destroy config objects they allocate internally. Caller-owned configs remain owned by the caller on failure. The reload path also keeps the parse result in a temporary pointer so a failed reload can destroy the caller-owned
new_cfand temporary context instead of leaking them.Tests
cmake --build build -j8ctest --test-dir build -R 'flb-it-(config_format_fluentbit|config_format_yaml|reload)' --output-on-failurevalgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./build/bin/flb-it-config_format_fluentbitvalgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./build/bin/flb-it-config_format_yamlvalgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./build/bin/flb-it-reload --exec=never reload_yaml_missing_includegit diff --check origin/master..HEAD/tmp/flb-commit-lint-11939/bin/python .github/scripts/commit_prefix_check.pyGITHUB_EVENT_NAME=pull_request GITHUB_BASE_REF=master /tmp/flb-commit-lint-11939/bin/python .github/scripts/commit_prefix_check.pySummary by CodeRabbit
Bug Fixes
Tests