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: init last_tag to fix valgrind warning #7247

Merged
merged 1 commit into from Sep 23, 2023

Conversation

nokute78
Copy link
Collaborator

@nokute78 nokute78 commented Apr 23, 2023

This patch is to fix following warning what I found while investigating #7234

==66582== Thread 2 flb-pipeline:
==66582== Conditional jump or move depends on uninitialised value(s)
==66582==    at 0x22E588: flb_router_match (flb_router.c:111)
==66582==    by 0x2456C0: flb_routes_mask_set_by_tag (flb_routes_mask.c:51)
==66582==    by 0x1CC70E: flb_input_chunk_create (flb_input_chunk.c:1018)
==66582==    by 0x1CD03F: input_chunk_get (flb_input_chunk.c:1268)
==66582==    by 0x1CDB18: input_chunk_append_raw (flb_input_chunk.c:1639)
==66582==    by 0x1CE688: flb_input_chunk_append_raw (flb_input_chunk.c:1989)
==66582==    by 0x2C4B41: input_log_append (flb_input_log.c:65)
==66582==    by 0x2C4BDC: flb_input_log_append (flb_input_log.c:84)
==66582==    by 0x343212: in_systemd_collect (systemd.c:185)
==66582==    by 0x343A3E: in_systemd_collect_archive (systemd.c:363)
==66582==    by 0x1C688D: flb_input_collector_fd (flb_input.c:1915)
==66582==    by 0x209EF6: flb_engine_handle_event (flb_engine.c:503)
==66582==    by 0x209EF6: flb_engine_start (flb_engine.c:866)
==66582== 

The tag of warning case is a last_tag of in_systemd.

int flb_router_match(const char *tag, int tag_len, const char *match,
                     void *match_regex)
{
    int ret;
    flb_sds_t t;

    if (tag[tag_len] != '\0') {

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.

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

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • [N/A] Backport to latest stable release.

Configuration

[Input]
    Name   systemd
    Tag    systemd.*

[OUTPUT]
    Name   null
    Match  systemd.*

Debug/Valgrind output

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

[2023/04/23 10:57:30] [ info] [fluent bit] version=2.1.1, commit=840d52649b, pid=63726
[2023/04/23 10:57:30] [ info] [storage] ver=1.2.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/04/23 10:57:30] [ info] [cmetrics] version=0.6.1
[2023/04/23 10:57:30] [ info] [ctraces ] version=0.3.0
[2023/04/23 10:57:30] [ info] [input:systemd:systemd.0] initializing
[2023/04/23 10:57:30] [ info] [input:systemd:systemd.0] storage_strategy='memory' (memory only)
[2023/04/23 10:57:30] [ info] [output:null:null.0] worker #0 started
[2023/04/23 10:57:30] [ info] [sp] stream processor started
^C[2023/04/23 10:59:54] [engine] caught signal (SIGINT)
[2023/04/23 11:00:00] [ warn] [engine] service will shutdown in max 5 seconds
[2023/04/23 11:00:00] [ info] [input] pausing systemd.0
[2023/04/23 11:00:01] [ info] [task] systemd/systemd.0 has 180 pending task(s):

(snip)

[2023/04/23 11:00:01] [ info] [input] pausing systemd.0
[2023/04/23 11:00:02] [ info] [engine] service has stopped (0 pending tasks)
[2023/04/23 11:00:02] [ info] [input] pausing systemd.0
[2023/04/23 11:00:02] [ info] [output:null:null.0] thread worker #0 stopping...
[2023/04/23 11:00:02] [ info] [output:null:null.0] thread worker #0 stopped
==63726== 
==63726== HEAP SUMMARY:
==63726==     in use at exit: 0 bytes in 0 blocks
==63726==   total heap usage: 1,175,402 allocs, 1,175,402 frees, 2,410,603,118 bytes allocated
==63726== 
==63726== All heap blocks were freed -- no leaks are possible
==63726== 
==63726== For lists of detected and suppressed errors, rerun with: -s
==63726== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

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 nokute78 temporarily deployed to pr April 23, 2023 02:07 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr April 23, 2023 02:07 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr April 23, 2023 02:07 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr April 23, 2023 02:31 — with GitHub Actions Inactive
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
@nokute78 nokute78 temporarily deployed to pr May 4, 2023 22:37 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr May 4, 2023 22:37 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr May 4, 2023 22:37 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr May 4, 2023 23:04 — with GitHub Actions Inactive
@nokute78 nokute78 changed the title in_system: init last_tag to fix valgrind warning in_systemd: init last_tag to fix valgrind warning May 28, 2023
@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 Aug 27, 2023
@nokute78
Copy link
Collaborator Author

ping

@github-actions github-actions bot removed the Stale label Aug 28, 2023
@edsiper edsiper merged commit 63f1578 into fluent:master Sep 23, 2023
39 of 42 checks passed
@nokute78 nokute78 deleted the in_systemd_touch_uninit branch September 24, 2023 00:54
leonardo-albertovich pushed a commit that referenced this pull request Oct 5, 2023
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
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.

None yet

2 participants