Skip to content
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

filter_parser: fix memory leak (#8614) #8712

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tomas-sve
Copy link

Summary

This fixes a memory leak in the Parser Filter plugin.

If you have several keys with the same name in a map and use the parser filter plugin with reserve_data set to true then it can assign out_buf multiple times resulting in leaked memory. This fix makes it continue copying original fields if reserve_data is set but stop parsing them, similar to when reserve_data is set to false.

Fixes #8614

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

If you have several keys with the same name in a map and use the parser filter
plugin with reserve_data set to true then it can assign out_buf multiple times
resulting in leaked memory. This fix makes it continue copying original fields
if reserve_data is set but stop parsing them, similar to when reserve_data is
set to false.
@tomas-sve
Copy link
Author

Example config/data to reproduce the bug can be found in #8614

Valgrind output (valgrind --leak-check=full) after fix:

==2520027==
==2520027== HEAP SUMMARY:
==2520027== in use at exit: 0 bytes in 0 blocks
==2520027== total heap usage: 32,333 allocs, 32,333 frees, 12,107,683 bytes allocated
==2520027==
==2520027== All heap blocks were freed -- no leaks are possible
==2520027==
==2520027== For lists of detected and suppressed errors, rerun with: -s
==2520027== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Valgrind output before fix can also be found in #8614

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double identical key/value pairs (+ memory leak) after regex parser, rewrite tag (and regex parser)
1 participant