Bug 283299 - sysutils/fluent-bit: crashes with a Bus Error
Summary: sysutils/fluent-bit: crashes with a Bus Error
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Palle Girgensohn
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-13 06:35 UTC by Antti Rasinen
Modified: 2025-01-07 11:11 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (girgen)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Rasinen 2024-12-13 06:35:04 UTC
With the 3.1.9 version in the 14 quarterly, my configuration that tries to send logs to Betterstack crashes with a Bus Error after the first attempted HTTP post. 

If I redirect the output also to console, I can see the first input row print out before the crash. If I remove the HTTP output, the program works normally.


The smallest input and output setup I can reproduce the bug with is the following:

[INPUT]
    tag siansaksa
    name random

[OUTPUT]
    name    http
    match   *
    tls     On
    host    in.logs.betterstack.com
    port    443
    uri     /fluentbit
    header  Authorization Bearer ###### personal token removed ######
    header  Content-Type application/msgpack
    format  msgpack
    retry_limit 5


Changing the format and content-type to json also causes the crash. The authorization token has been confirmed to be correct using a direct curl post.
Comment 1 Palle Girgensohn freebsd_committer freebsd_triage 2024-12-13 10:05:26 UTC
Hi!

Does the fluent-bit-3.2.2 still show the same problem?

Regards,
Palle
Comment 2 Antti Rasinen 2024-12-13 10:10:27 UTC
(In reply to Palle Girgensohn from comment #1)

Do I have a good way of installing without disturbing the rest of my (quarterly) installation?
Comment 3 Antti Rasinen 2024-12-13 10:17:33 UTC
(In reply to Antti Rasinen from comment #2)

Alright, managed to install it, will check after lunch.
Comment 4 Antti Rasinen 2024-12-13 10:19:53 UTC
Decided to check at once since my lunch mate got a phone call. Yes, still happening:

$ doas -u nobody /usr/local/bin/fluent-bit -c /usr/local/etc/fluent-bit/fluent-bit.conf
Password:
[2024/12/13 12:18:45] [ info] [config] changing coro_stack_size from 3072 to 4096 bytes
Fluent Bit v3.2.2
* 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/13 12:18:45] [ info] [fluent bit] version=3.2.2, commit=, pid=23342
[2024/12/13 12:18:45] [ info] [storage] ver=1.5.2, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2024/12/13 12:18:45] [ info] [simd    ] disabled
[2024/12/13 12:18:45] [ info] [cmetrics] version=0.9.9
[2024/12/13 12:18:45] [ info] [ctraces ] version=0.5.7
[2024/12/13 12:18:45] [ info] [input:tail:tail.0] initializing
[2024/12/13 12:18:45] [ info] [input:tail:tail.0] storage_strategy='memory' (memory only)
[2024/12/13 12:18:45] [ info] [input:random:random.1] initializing
[2024/12/13 12:18:45] [ info] [input:random:random.1] storage_strategy='memory' (memory only)
[2024/12/13 12:18:45] [ info] [output:stdout:stdout.0] worker #0 started
[2024/12/13 12:18:45] [ info] [sp] stream processor started
[2024/12/13 12:18:45] [ info] [output:http:http.1] worker #0 started
[2024/12/13 12:18:45] [ info] [output:http:http.1] worker #1 started
{"date":1734085126.234562,"rand_value":6488732564125523264}
Bus error
Comment 5 Palle Girgensohn freebsd_committer freebsd_triage 2024-12-13 10:28:17 UTC
I suggest reporting this upstreams, since it is unlikely this is specific to the way the port builds. Would you be OK taking lead on that, since you can reproduce the problem?

https://github.com/fluent/fluent-bit/issues

Regards,
Palle
Comment 6 Antti Rasinen 2024-12-13 10:58:24 UTC
Roger that
Comment 7 Antti Rasinen 2024-12-13 11:23:52 UTC
Upstream ticket: https://github.com/fluent/fluent-bit/issues/9722
Comment 8 commit-hook freebsd_committer freebsd_triage 2025-01-06 22:56:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=83d8d3bd7aca28814c400828d5d4738294297325

commit 83d8d3bd7aca28814c400828d5d4738294297325
Author:     Palle Girgensohn <girgen@FreeBSD.org>
AuthorDate: 2025-01-06 21:52:26 +0000
Commit:     Palle Girgensohn <girgen@FreeBSD.org>
CommitDate: 2025-01-06 22:56:37 +0000

    sysutils/fluent-bit: Upgrade to 3.2.4

    Hard code the coro stack size to something that is expected.
    Documentation states that 24576 is default [1] but FreeBSD has a
    PTHREAD_MIN_SIZE of only 4 * 512, so the coro stack size is just too
    small for some use cases [2].

    [1] https://docs.fluentbit.io/manual/administration/configuring-fluent-bit
    PR:     283299 (reported by Antti Rasinen) |2]

    Release notes:  https://github.com/fluent/fluent-bit/releases/tag/v3.2.4

 sysutils/fluent-bit/Makefile                              |  2 +-
 sysutils/fluent-bit/distinfo                              |  6 +++---
 sysutils/fluent-bit/files/patch-include__flb_coro.h (new) | 14 ++++++++++++++
 sysutils/fluent-bit/pkg-plist                             |  1 +
 4 files changed, 19 insertions(+), 4 deletions(-)
Comment 9 Palle Girgensohn freebsd_committer freebsd_triage 2025-01-06 22:59:07 UTC
(In reply to commit-hook from comment #8)
So I hard code the stack size according to the documentation at https://docs.fluentbit.io/manual/administration/configuring-fluent-bit. It seems that this makes most sense. I've tested the simple example and it does not crash for the first few rounds.

Please verify that this helps, so I can possibly close the tickes.

Palle
Comment 10 Antti Rasinen 2025-01-07 11:05:35 UTC
Works for me
Comment 11 Antti Rasinen 2025-01-07 11:05:48 UTC
Works for me
Comment 12 Palle Girgensohn freebsd_committer freebsd_triage 2025-01-07 11:11:54 UTC
Fix committed. Discussion about adding it upstreams is ongoing at https://github.com/fluent/fluent-bit/issues/9722#issuecomment-2575010933