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

in_systemd: fix memory leak #9773

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

Conversation

bpetermannS11
Copy link

Fix a memory leak in the systemd input plugin.
If option "lowercase" was on, the temporary buffer to convert a key to the lower-case string was not freed.

Fixes #9769


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
  • 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

Backporting

  • Backport to latest stable release.

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.

@bpetermannS11
Copy link
Author

Example configuration

[INPUT]
    name              systemd
    tag               journald
    db                /var/log/fluent-bit/fluent-bit-journal.db
    lowercase         on
    path              /var/log/journal

@bpetermannS11
Copy link
Author

Valgrind/debug output

valgrind --leak-check=full ~bpetermann/fluent-bit-bp/build/bin/fluent-bit -c fluent-bit.conf
==71649== Memcheck, a memory error detector
==71649== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==71649== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==71649== Command: /home/bpetermann/fluent-bit-bp/build/bin/fluent-bit -c fluent-bit.conf
==71649==
Fluent Bit v3.2.4
* Copyright (C) 2015-2024 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____
|  ___| |                | |   | ___ (_) |         |____ |/ __  \
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   __   / /`' / /'
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \  / /
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V /.___/ /./ /___
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)_____/


[2024/12/27 13:00:29] [ info] [fluent bit] version=3.2.4, commit=d77c06dc6c, pid=71649
[2024/12/27 13:00:29] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/12/27 13:00:29] [ info] [simd    ] disabled
[2024/12/27 13:00:29] [ info] [cmetrics] version=0.9.9
[2024/12/27 13:00:29] [ info] [ctraces ] version=0.5.7
[2024/12/27 13:00:29] [ info] [input:systemd:systemd.0] initializing
[2024/12/27 13:00:29] [ info] [input:systemd:systemd.0] storage_strategy='memory' (memory only)
[2024/12/27 13:00:30] [ info] [input:systemd:systemd.0] seek_cursor=s=e33aefeeefa44645b4ee468c56cf6de8;i=999... OK
[2024/12/27 13:00:30] [ info] [sp] stream processor started
^C[2024/12/27 13:00:45] [engine] caught signal (SIGINT)
[2024/12/27 13:00:45] [ warn] [engine] service will shutdown in max 5 seconds
[2024/12/27 13:00:45] [ info] [input] pausing systemd.0
[2024/12/27 13:00:45] [ info] [engine] service has stopped (0 pending tasks)
[2024/12/27 13:00:45] [ info] [input] pausing systemd.0
==71649==
==71649== HEAP SUMMARY:
==71649==     in use at exit: 0 bytes in 0 blocks
==71649==   total heap usage: 2,944 allocs, 2,944 frees, 1,425,156 bytes allocated
==71649==
==71649== All heap blocks were freed -- no leaks are possible
==71649==
==71649== For lists of detected and suppressed errors, rerun with: -s
==71649== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Fix a memory leak in the systemd input plugin.
If option "lowercase" was on, the temporary buffer to
convert a key to the lower-case string was not freed.

Signed-off-by: Bodo Petermann <[email protected]>
@bpetermannS11 bpetermannS11 force-pushed the bugfix/memory-leak-systemd-plugin branch from b26d9a4 to 0e8a72a Compare December 27, 2024 13:14
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.

Memory Leak running Fluent-bit v3.2.3
1 participant