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

out_oracle_log_analytics: minor fixes #7966

Merged
merged 5 commits into from
Aug 5, 2024

Conversation

nokute78
Copy link
Collaborator

This patch is to

  1. Remove some flb_errno. We should use flb_errno for syscall error.
  2. Release key to prevent leak.
  3. Fix mk_list handling. Always initialize mk_list.
  4. Set NULL to prevent double free.

3 is to fix following SIGSEGV. It caused by touching not initalized mk_list.

$ bin/fluent-bit -i dummy -o oracle_log_analytics 
Fluent Bit v2.1.10
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/09/24 09:20:53] [engine] caught signal (SIGSEGV)
[2023/09/24 09:20:53] [ info] [fluent bit] version=2.1.10, commit=2631ca199e, pid=60103
[2023/09/24 09:20:53] [ info] [storage] ver=1.2.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/09/24 09:20:53] [ info] [cmetrics] version=0.6.3
[2023/09/24 09:20:53] [ info] [ctraces ] version=0.3.1
[2023/09/24 09:20:53] [ info] [input:dummy:dummy.0] initializing
[2023/09/24 09:20:53] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2023/09/24 09:20:53] [error] [/home/taka/git/fluent-bit/plugins/out_oracle_log_analytics/oci_logan_conf.c:293 errno=0] Success
[2023/09/24 09:20:53] [error] [output:oracle_log_analytics:oracle_log_analytics.0] log source name and log group id are required
#0  0x563a2fe7abae      in  metadata_fields_destroy() at plugins/out_oracle_log_analytics/oci_logan_conf.c:438
#1  0x563a2fe7ae18      in  flb_oci_logan_conf_destroy() at plugins/out_oracle_log_analytics/oci_logan_conf.c:489
#2  0x563a2fe7a278      in  flb_oci_logan_conf_create() at plugins/out_oracle_log_analytics/oci_logan_conf.c:296
#3  0x563a2fe72a01      in  cb_oci_logan_init() at plugins/out_oracle_log_analytics/oci_logan.c:533
#4  0x563a2fa21227      in  flb_output_init_all() at src/flb_output.c:1301
#5  0x563a2fa48e28      in  flb_engine_start() at src/flb_engine.c:790
#6  0x563a2f9e3944      in  flb_lib_worker() at src/flb_lib.c:638
#7  0x7fb2f6a94b42      in  start_thread() at /sysdeps/unix/sysv/linux/rseq-internal.h:442
#8  0x7fb2f6b269ff      in  ???() at /x86_64/clone3.S:81
#9  0xffffffffffffffff  in  ???() at ???:0
Aborted (core dumped)

4 is to fix following double free.

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

[2023/09/24 09:21:37] [ info] [fluent bit] version=2.1.10, commit=2631ca199e, pid=60108
[2023/09/24 09:21:37] [ info] [storage] ver=1.2.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/09/24 09:21:37] [ info] [cmetrics] version=0.6.3
[2023/09/24 09:21:37] [ info] [ctraces ] version=0.3.1
[2023/09/24 09:21:37] [ info] [input:dummy:dummy.0] initializing
[2023/09/24 09:21:37] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
==60108== Thread 2 flb-pipeline:
==60108== Invalid free() / delete / delete[] / realloc()
==60108==    at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==60108==    by 0x67016E: mk_mem_free (mk_memory.h:102)
==60108==    by 0x674C3B: load_oci_credentials (oci_logan_conf.c:159)
==60108==    by 0x67543C: flb_oci_logan_conf_create (oci_logan_conf.c:327)
==60108==    by 0x66DA01: cb_oci_logan_init (oci_logan.c:533)
==60108==    by 0x21C227: flb_output_init_all (flb_output.c:1301)
==60108==    by 0x243E28: flb_engine_start (flb_engine.c:790)
==60108==    by 0x1DE944: flb_lib_worker (flb_lib.c:638)
==60108==    by 0x4FF3B42: start_thread (pthread_create.c:442)
==60108==    by 0x5084BB3: clone (clone.S:100)
==60108==  Address 0x547df70 is 0 bytes inside a block of size 6 free'd
==60108==    at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==60108==    by 0x67016E: mk_mem_free (mk_memory.h:102)
==60108==    by 0x674942: load_oci_credentials (oci_logan_conf.c:123)
==60108==    by 0x67543C: flb_oci_logan_conf_create (oci_logan_conf.c:327)
==60108==    by 0x66DA01: cb_oci_logan_init (oci_logan.c:533)
==60108==    by 0x21C227: flb_output_init_all (flb_output.c:1301)
==60108==    by 0x243E28: flb_engine_start (flb_engine.c:790)
==60108==    by 0x1DE944: flb_lib_worker (flb_lib.c:638)
==60108==    by 0x4FF3B42: start_thread (pthread_create.c:442)
==60108==    by 0x5084BB3: clone (clone.S:100)
==60108==  Block was alloc'd at
==60108==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==60108==    by 0xE5591D: mk_mem_alloc (mk_memory.h:53)
==60108==    by 0xE56733: mk_string_copy_substr (mk_string.c:585)
==60108==    by 0x67486C: load_oci_credentials (oci_logan_conf.c:117)
==60108==    by 0x67543C: flb_oci_logan_conf_create (oci_logan_conf.c:327)
==60108==    by 0x66DA01: cb_oci_logan_init (oci_logan.c:533)
==60108==    by 0x21C227: flb_output_init_all (flb_output.c:1301)
==60108==    by 0x243E28: flb_engine_start (flb_engine.c:790)
==60108==    by 0x1DE944: flb_lib_worker (flb_lib.c:638)
==60108==    by 0x4FF3B42: start_thread (pthread_create.c:442)
==60108==    by 0x5084BB3: clone (clone.S:100)
==60108== 

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

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

Configuration

[INPUT]
    Name dummy

[OUTPUT]
    name  oracle_log_analytics
    oci_la_log_source_name hoge
    oci_la_log_group_id hoge
    config_file_location a.conf

Debug/Valgrind output

Valgrind reported error that is not related this PR.

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

[2023/09/24 09:15:35] [ info] [fluent bit] version=2.1.10, commit=2631ca199e, pid=57351
[2023/09/24 09:15:35] [ info] [storage] ver=1.2.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/09/24 09:15:35] [ info] [cmetrics] version=0.6.3
[2023/09/24 09:15:35] [ info] [ctraces ] version=0.3.1
[2023/09/24 09:15:35] [ info] [input:dummy:dummy.0] initializing
[2023/09/24 09:15:35] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2023/09/24 09:15:35] [error] [/home/taka/git/fluent-bit/plugins/out_oracle_log_analytics/oci_logan_conf.c:170 errno=0] Success
[2023/09/24 09:15:35] [error] [/home/taka/git/fluent-bit/plugins/out_oracle_log_analytics/oci_logan_conf.c:331 errno=0] Success
[2023/09/24 09:15:35] [error] [output:oracle_log_analytics:oracle_log_analytics.0] cannot initialize plugin
[2023/09/24 09:15:35] [error] [output] failed to initialize 'oracle_log_analytics' plugin
[2023/09/24 09:15:35] [error] [engine] output initialization failed
[2023/09/24 09:15:35] [error] [lib] backend failed
[2023/09/24 09:15:36] [ info] [input] pausing dummy.0
==57351== 
==57351== HEAP SUMMARY:
==57351==     in use at exit: 7 bytes in 1 blocks
==57351==   total heap usage: 1,478 allocs, 1,477 frees, 287,329 bytes allocated
==57351== 
==57351== 7 bytes in 1 blocks are definitely lost in loss record 1 of 1
==57351==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==57351==    by 0x1C4E60: flb_malloc (flb_mem.h:80)
==57351==    by 0x1C514A: flb_strndup (flb_str.h:34)
==57351==    by 0x1C51B1: flb_strdup (flb_str.h:46)
==57351==    by 0x1C781C: flb_main (fluent-bit.c:970)
==57351==    by 0x1C8594: main (fluent-bit.c:1415)
==57351== 
==57351== LEAK SUMMARY:
==57351==    definitely lost: 7 bytes in 1 blocks
==57351==    indirectly lost: 0 bytes in 0 blocks
==57351==      possibly lost: 0 bytes in 0 blocks
==57351==    still reachable: 0 bytes in 0 blocks
==57351==         suppressed: 0 bytes in 0 blocks
==57351== 
==57351== For lists of detected and suppressed errors, rerun with: -s
==57351== ERROR SUMMARY: 1 errors from 1 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 September 24, 2023 00:22 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr September 24, 2023 00:22 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr September 24, 2023 00:22 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr September 24, 2023 00:49 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr September 30, 2023 05:41 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr September 30, 2023 05:41 — with GitHub Actions Inactive
@nokute78 nokute78 temporarily deployed to pr September 30, 2023 05:41 — with GitHub Actions Inactive
@nokute78
Copy link
Collaborator Author

I merged the branch with master

@nokute78 nokute78 temporarily deployed to pr September 30, 2023 06:07 — with GitHub Actions Inactive
@patrick-stephens
Copy link
Contributor

@edsiper apologies if already discussed but should @adiforluls be added as code-owner for this plugin?

@adiforluls
Copy link
Member

Thanks for the fixes @nokute78, LGTM

Copy link
Contributor

github-actions bot commented Jan 8, 2024

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 Jan 8, 2024
@nokute78
Copy link
Collaborator Author

nokute78 commented Feb 2, 2024

@edsiper @leonardo-albertovich ping

@github-actions github-actions bot removed the Stale label Feb 3, 2024
Copy link
Contributor

github-actions bot commented May 3, 2024

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.

Copy link
Contributor

github-actions bot commented Aug 3, 2024

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 3, 2024
@leonardo-albertovich leonardo-albertovich added this to the Fluent Bit v3.1.5 milestone Aug 5, 2024
@edsiper edsiper merged commit e19b2ab into fluent:master Aug 5, 2024
41 checks passed
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.

5 participants