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

plugin_proxy: destroy used buffer on exit #3888

Merged
merged 5 commits into from
Dec 12, 2021

Conversation

nokute78
Copy link
Collaborator

@nokute78 nokute78 commented Jul 29, 2021

plugin_proxy leaks several times. I fixed.


Enter [N/A] in the box, if an item is not applicable to your change.

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

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

Documentation

  • [N/A] Documentation required for this feature

Configuration file

It is same as #3863 (comment)


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.

nokute78 added 5 commits July 29, 2021 21:44
Almost output plugins's out->name/description are const char*.
Then they are not freed on destroy callback.

Signed-off-by: Takahiro Yamashita <[email protected]>
@nokute78
Copy link
Collaborator Author

The below is an output of valgrind current master

Leak of name and description

30e0bab is to fix.
The name and description are should not use heap since almost plugin uses const char*.

==9145== 8 bytes in 1 blocks are definitely lost in loss record 3 of 17
==9145==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==9145==    by 0x1D4937: flb_malloc (flb_mem.h:62)
==9145==    by 0x1D4A00: flb_strdup (flb_str.h:37)
==9145==    by 0x1D4D74: flb_proxy_register_output (flb_plugin_proxy.c:107)
==9145==    by 0x1D4EF6: flb_plugin_proxy_register (flb_plugin_proxy.c:181)
==9145==    by 0x1D50AB: flb_plugin_proxy_create (flb_plugin_proxy.c:248)
==9145==    by 0x1C66CF: flb_plugin_load_router (flb_plugin.c:311)
==9145==    by 0x1C694F: flb_plugin_load_config_file (flb_plugin.c:379)
==9145==    by 0x1B2CD4: flb_config_set_property (flb_config.c:515)
==9145==    by 0x192696: flb_service_conf (fluent-bit.c:759)
==9145==    by 0x193356: flb_main (fluent-bit.c:1142)
==9145==    by 0x193533: main (fluent-bit.c:1221)
==9145== 
==9145== 11 bytes in 1 blocks are definitely lost in loss record 4 of 17
==9145==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==9145==    by 0x1D4937: flb_malloc (flb_mem.h:62)
==9145==    by 0x1D4A00: flb_strdup (flb_str.h:37)
==9145==    by 0x1D4D8C: flb_proxy_register_output (flb_plugin_proxy.c:108)
==9145==    by 0x1D4EF6: flb_plugin_proxy_register (flb_plugin_proxy.c:181)
==9145==    by 0x1D50AB: flb_plugin_proxy_create (flb_plugin_proxy.c:248)
==9145==    by 0x1C66CF: flb_plugin_load_router (flb_plugin.c:311)
==9145==    by 0x1C694F: flb_plugin_load_config_file (flb_plugin.c:379)
==9145==    by 0x1B2CD4: flb_config_set_property (flb_config.c:515)
==9145==    by 0x192696: flb_service_conf (fluent-bit.c:759)
==9145==    by 0x193356: flb_main (fluent-bit.c:1142)
==9145==    by 0x193533: main (fluent-bit.c:1221)

Leak of flb_plugin_proxy_def

1a359fd is to fix.
The struct is not saved as a member of plugin instance.
I added it to flb_plugin_proxy and released on destructor.

==9145== 51 (32 direct, 19 indirect) bytes in 1 blocks are definitely lost in loss record 9 of 17
==9145==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==9145==    by 0x1D4937: flb_malloc (flb_mem.h:62)
==9145==    by 0x1D4E59: flb_plugin_proxy_register (flb_plugin_proxy.c:152)
==9145==    by 0x1D50AB: flb_plugin_proxy_create (flb_plugin_proxy.c:248)
==9145==    by 0x1C66CF: flb_plugin_load_router (flb_plugin.c:311)
==9145==    by 0x1C694F: flb_plugin_load_config_file (flb_plugin.c:379)
==9145==    by 0x1B2CD4: flb_config_set_property (flb_config.c:515)
==9145==    by 0x192696: flb_service_conf (fluent-bit.c:759)
==9145==    by 0x193356: flb_main (fluent-bit.c:1142)
==9145==    by 0x193533: main (fluent-bit.c:1221)
==9145== 

Leak of flb_plugin_proxy

6d27f38 is to fix.
Invoking destruct function.

==9145== 176 (72 direct, 104 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 17
==9145==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==9145==    by 0x1D4937: flb_malloc (flb_mem.h:62)
==9145==    by 0x1D4FE0: flb_plugin_proxy_create (flb_plugin_proxy.c:226)
==9145==    by 0x1C66CF: flb_plugin_load_router (flb_plugin.c:311)
==9145==    by 0x1C694F: flb_plugin_load_config_file (flb_plugin.c:379)
==9145==    by 0x1B2CD4: flb_config_set_property (flb_config.c:515)
==9145==    by 0x192696: flb_service_conf (fluent-bit.c:759)
==9145==    by 0x193356: flb_main (fluent-bit.c:1142)
==9145==    by 0x193533: main (fluent-bit.c:1221)

@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Sep 27, 2021
@nokute78 nokute78 removed the Stale label Sep 27, 2021
@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Oct 28, 2021
@nokute78 nokute78 removed the Stale label Oct 30, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2021

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Dec 2, 2021
@nokute78 nokute78 removed the Stale label Dec 2, 2021
@edsiper edsiper merged commit 83686a5 into fluent:master Dec 12, 2021
@nokute78 nokute78 deleted the cleanup_proxy branch December 12, 2021 07:56
0Delta pushed a commit to 0Delta/fluent-bit that referenced this pull request Jan 20, 2022
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.

2 participants