Skip to content

in_dummy: Use pre_run callback to fix crash path#11753

Merged
edsiper merged 2 commits intomasterfrom
cosmo0920-change-initialization-order-for-filters-and-inputs
Apr 28, 2026
Merged

in_dummy: Use pre_run callback to fix crash path#11753
edsiper merged 2 commits intomasterfrom
cosmo0920-change-initialization-order-for-filters-and-inputs

Conversation

@cosmo0920
Copy link
Copy Markdown
Contributor

@cosmo0920 cosmo0920 commented Apr 28, 2026

Fixed the root cause in dummy plugin. This ensures startup emissions on in_dummy with flush_on_startup=true do not cause SEGV crash.

Closes #11751.


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

The previously repro and fixed SEGV config is:
#11751 (comment)

  • Debug log output from testing the change
* Copyright (C) 2015-2026 The Fluent Bit Authors
* Fluent Bit is a CNCF graduated project under the Fluent organization
* https://fluentbit.io

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


[2026/04/28 15:17:50.365] [ info] Configuration:
[2026/04/28 15:17:50.365] [ info]  flush time     | 1.000000 seconds
[2026/04/28 15:17:50.365] [ info]  grace          | 5 seconds
[2026/04/28 15:17:50.365] [ info]  daemon         | 0
[2026/04/28 15:17:50.365] [ info] ___________
[2026/04/28 15:17:50.365] [ info]  inputs:
[2026/04/28 15:17:50.365] [ info]      dummy
[2026/04/28 15:17:50.365] [ info] ___________
[2026/04/28 15:17:50.365] [ info]  filters:
[2026/04/28 15:17:50.365] [ info]      lua.0
[2026/04/28 15:17:50.365] [ info] ___________
[2026/04/28 15:17:50.365] [ info]  outputs:
[2026/04/28 15:17:50.365] [ info]      stdout.0
[2026/04/28 15:17:50.365] [ info] ___________
[2026/04/28 15:17:50.365] [ info]  collectors:
[2026/04/28 15:17:50.365] [ info] [fluent bit] version=5.0.4, commit=8c0880a8d8, pid=89166
[2026/04/28 15:17:50.365] [debug] [engine] coroutine stack size: 36864 bytes (36.0K)
[2026/04/28 15:17:50.365] [ info] [storage] ver=1.4.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2026/04/28 15:17:50.365] [ info] [simd    ] NEON
[2026/04/28 15:17:50.365] [ info] [cmetrics] version=2.1.2
[2026/04/28 15:17:50.365] [ info] [ctraces ] version=0.7.1
[2026/04/28 15:17:50.365] [ info] [input:dummy:dummy.0] initializing
[2026/04/28 15:17:50.365] [ info] [input:dummy:dummy.0] storage_strategy='memory' (memory only)
[2026/04/28 15:17:50.365] [debug] [dummy:dummy.0] created event channels: read=21 write=22
[2026/04/28 15:17:50.366] [debug] [stdout:stdout.0] created event channels: read=23 write=24
[2026/04/28 15:17:50.366] [ info] [output:stdout:stdout.0] worker #0 started
[2026/04/28 15:17:50.366] [ info] [sp] stream processor started
[2026/04/28 15:17:50.366] [ info] [engine] Shutdown Grace Period=5, Shutdown Input Grace Period=2
[2026/04/28 15:17:51.370] [debug] [task] created task=0x105a0c080 id=0 OK
[2026/04/28 15:17:51.370] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[0] dummy.0: [[1777357070.366138000, {}], {"message"=>"dummy", "check"=>"checkval"}]
[2026/04/28 15:17:51.370] [debug] [out flush] cb_destroy coro_id=0
[2026/04/28 15:17:51.370] [debug] [task] destroy task=0x105a0c080 (task_id=0)
[2026/04/28 15:17:56.370] [debug] [task] created task=0x105a0c180 id=0 OK
[2026/04/28 15:17:56.370] [debug] [output:stdout:stdout.0] task_id=0 assigned to thread #0
[0] dummy.0: [[1777357075.370458000, {}], {"message"=>"dummy", "check"=>"checkval"}]
[2026/04/28 15:17:56.370] [debug] [out flush] cb_destroy coro_id=1
[2026/04/28 15:17:56.370] [debug] [task] destroy task=0x105a0c180 (task_id=0)
^C[2026/04/28 15:17:56] [engine] caught signal (SIGINT)
[2026/04/28 15:17:56.861] [ info] [input] pausing dummy.0
[2026/04/28 15:17:56.861] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2026/04/28 15:17:56.861] [ info] [output:stdout:stdout.0] thread worker #0 stopped
  • Attached Valgrind output that shows no leaks or memory corruption was found
Process 78573 is not debuggable. Due to security restrictions, leaks can only show or save contents of readonly memory of restricted processes.

Process:         fluent-bit [78573]
Path:            /Users/USER/*/fluent-bit
Load Address:    0x1042b8000
Identifier:      fluent-bit
Version:         0
Code Type:       ARM64
Platform:        macOS
Parent Process:  leaks [78572]
Target Type:     live task

Date/Time:       2026-04-28 14:58:14.693 +0900
Launch Time:     2026-04-28 14:58:04.631 +0900
OS Version:      macOS 26.4.1 (25E253)
Report Version:  7
Analysis Tool:   /usr/bin/leaks

Physical footprint:         7601K
Physical footprint (peak):  7729K
Idle exit:                  untracked
----

leaks Report Version: 4.0, multi-line stacks
Process 78573: 1332 nodes malloced for 203 KB
Process 78573: 0 leaks for 0 total leaked bytes.

[2026/04/28 14:58:16] [engine] caught signal (SIGCONT)

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

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved accuracy of plugin initialization error messages to correctly identify whether filter or input initialization failed.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

The changes address a crash occurring when dummy input with flush_on_startup=true is combined with a Lua filter. The fix relocates the flush-on-startup event generation from the initialization phase to a pre-run callback, altering the execution sequence. A new test validates this corrected behavior.

Changes

Cohort / File(s) Summary
Dummy Input Plugin
plugins/in_dummy/in_dummy.c
Moved flush_on_startup event generation from in_dummy_init to a new in_dummy_pre_run callback function; updated plugin's cb_pre_run entry point from NULL to in_dummy_pre_run.
Lua Filter Test Suite
tests/runtime/filter_lua.c
Added flb_test_dummy_flush_on_startup() runtime test that verifies dummy input with flush_on_startup=true interacts correctly with Lua filters; registered test in TEST_LIST.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A crash did lurk when startup flushed,
With Lua's dance too swift, too rushed,
We moved the call to time it right,
Pre-run's the stage, the flow's now bright!
And tests now guard this dance of fate.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'in_dummy: Use pre_run callback to fix crash path' accurately describes the main change: moving flush_on_startup logic to a pre_run callback.
Linked Issues check ✅ Passed The pull request addresses issue #11751 by fixing the crash that occurs when dummy input with flush_on_startup is used with a lua filter, and includes a test case validating the corrected behavior.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the crash path: relocating flush_on_startup from init to pre_run callback in in_dummy, and adding a test to validate the fix.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-change-initialization-order-for-filters-and-inputs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 452e51a16f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/flb_engine.c Outdated
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@cosmo0920 cosmo0920 force-pushed the cosmo0920-change-initialization-order-for-filters-and-inputs branch from 452e51a to 96a1df8 Compare April 28, 2026 06:16
@cosmo0920 cosmo0920 changed the title engine: Change initialization order for filters and inputs in_dummy: Use pre_run callback to fix crash path Apr 28, 2026
@cosmo0920
Copy link
Copy Markdown
Contributor Author

@codex review

@edsiper edsiper merged commit 3e8caad into master Apr 28, 2026
82 of 84 checks passed
@edsiper edsiper deleted the cosmo0920-change-initialization-order-for-filters-and-inputs branch April 28, 2026 15:13
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.

Fluent Bit crashes with dummy has flush_on_startup true and has a lua filter

2 participants