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

Segv from simple wildcard #7368

Closed
mnp opened this issue May 12, 2023 · 2 comments · Fixed by #7378
Closed

Segv from simple wildcard #7368

mnp opened this issue May 12, 2023 · 2 comments · Fixed by #7378

Comments

@mnp
Copy link

mnp commented May 12, 2023

Bug Report

Describe the bug
SIGSEGV

To Reproduce

$ docker run -v `pwd`:/foo --rm -it fluent/fluent-bit -c /foo/conf
Fluent Bit v2.1.2
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/05/12 01:28:53] [ info] [fluent bit] version=2.1.2, commit=113c7c00d2, pid=1
[2023/05/12 01:28:53] [ info] [storage] ver=1.4.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/05/12 01:28:53] [ info] [cmetrics] version=0.6.1
[2023/05/12 01:28:53] [ info] [ctraces ] version=0.3.0
[2023/05/12 01:28:53] [ info] [input:dummy:dummy.0] initializing
[2023/05/12 01:28:53] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
ret=-113. start=*s3 end=
ret=-113. start=*s3 end=
[2023/05/12 01:28:53] [debug] [filter:modify:modify.0] Initialized modify filter with 0 conditions and 1 rules
[2023/05/12 01:28:53] [ info] [sp] stream processor started
[2023/05/12 01:28:53] [ info] [output:stdout:stdout.0] worker #0 started
[2023/05/12 01:28:55] [ warn] [engine] service will shutdown in max 2 seconds
[2023/05/12 01:28:55] [ info] [input] pausing dummy.0
[0] dummy.0: [[1683854934.165236446, {}], {"r1"=>"someval", "s1"=>{"s2"=>nil, "s3"=>nil}, "r2"=>{"x"=>0}}]
[2023/05/12 01:28:56] [ info] [engine] service has stopped (0 pending tasks)
[2023/05/12 01:28:56] [ info] [input] pausing dummy.0
[2023/05/12 01:28:56] [engine] caught signal (SIGSEGV)
#0  0x5599036f4623      in  flb_regex_destroy() at src/flb_regex.c:312
#1  0x559903b2f227      in  teardown() at plugins/filter_modify/modify.c:82
#2  0x559903b3419c      in  cb_modify_exit() at plugins/filter_modify/modify.c:1531
#3  0x559903642f90      in  flb_filter_instance_exit() at src/flb_filter.c:352
#4  0x559903642ff6      in  flb_filter_exit() at src/flb_filter.c:370
#5  0x55990366f1f6      in  flb_engine_shutdown() at src/flb_engine.c:1046
#6  0x55990366ee62      in  flb_engine_start() at src/flb_engine.c:942
#7  0x559903613531      in  flb_lib_worker() at src/flb_lib.c:638
#8  0x7f94f304bea6      in  ???() at ???:0
#9  0x7f94f28fea2e      in  ???() at ???:0
#10 0xffffffffffffffff  in  ???() at ???:0
  • Steps to reproduce the problem:

Expected behavior
Print an error saying what I did wrong and continue.

Your Environment

  • Version used: docker x86 v2.1.2
  • Configuration:
[SERVICE]
    Flush      1
    Grace      2
    Log_Level  info

[INPUT]
    Name       dummy
    Dummy      {"r1": "someval", "s1": {"s2": null, "s3": null}, "r2": {"x": 0}}
    Samples    1

[FILTER]
    Name                 modify
    Match                *
    Log_Level            debug
    Remove_wildcard      *s3

[OUTPUT]
    Name  stdout
    Match *

[OUTPUT]
    Name exit
    Match *

Additional context
I suspect it's the bad wildcard.

@leonardo-albertovich
Copy link
Collaborator

The problem is that the filters initialization routine has a few flaws :

  1. The regex compilation results are not checked and thus an invalid regex will just leave an invalid value (NULL) in place which will be later on used and I suspect that wouldn't go well. << this is NOT your case
  2. The teardown routine unconditionally tries to dispose of all the rule components without checking their state (ie. a regex field wasn't or couldn't be initialized).

Would you like to take a stab at fixing it? I can't give you an ETA for the fix but I can provide any assistance you might need if you try to contribute a patch.

Thanks for reporting this issue.

nokute78 added a commit to nokute78/fluent-bit that referenced this issue May 12, 2023
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
@nokute78
Copy link
Collaborator

I sent a patch #7378

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

Successfully merging a pull request may close this issue.

3 participants