Skip to content

build fixes: out_stackdriver int64_t line var, gzip endian-safe magic check - #12045

Merged
edsiper merged 2 commits into
masterfrom
out_stackdriver-fix-int64-build
Jul 4, 2026
Merged

build fixes: out_stackdriver int64_t line var, gzip endian-safe magic check#12045
edsiper merged 2 commits into
masterfrom
out_stackdriver-fix-int64-build

Conversation

@edsiper

@edsiper edsiper commented Jul 4, 2026

Copy link
Copy Markdown
Member

Two build/CI fixes found while investigating the failed v5.0.9 staging build (https://github.com/fluent/fluent-bit/actions/runs/28693445706/job/85098879153):

1. out_stackdriver: use int64_t for source_location_line

On 32-bit targets (arm/v7) long is 32-bit while int64_t is long long, so stackdriver_format() failed to compile when passing &source_location_line to extract_source_location(), which expects int64_t *:

/src/fluent-bit/plugins/out_stackdriver/stackdriver.c:2450:61: error: passing argument 2 of 'extract_source_location' from incompatible pointer type [-Wincompatible-pointer-types]
note: expected 'int64_t *' {aka 'long long int *'} but argument is of type 'long int *'

Declare the variable as int64_t to match the function signature on all architectures.

2. gzip: read magic number endian-safely in streaming decompressor

Found via the s390x unit-test job on this PR: the gzip header magic was memcpy'd into a uint16_t and compared against 0x8B1F, which only holds on little-endian hosts. On big-endian targets a valid stream was rejected with invalid magic bytes : 1f8b. Read the field with read_le16() so the comparison works regardless of host byte order.


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:

  • [N/A] Example configuration file for the change
  • Debug log output from testing the change
  • [N/A] 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.

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.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved source line number handling for Stackdriver output to better preserve accuracy with larger values.
    • Fixed gzip header validation to correctly interpret stored magic bytes as little-endian, with clearer error reporting when validation fails.

On 32-bit targets (arm/v7) 'long' is 32-bit while int64_t is
'long long', so passing &source_location_line to
extract_source_location() failed to compile with
-Wincompatible-pointer-types. Declare the variable as int64_t to
match the function signature on all architectures.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR changes the Stackdriver output plugin’s source line variable type and updates gzip header magic-byte validation to decode the stored value as little-endian before comparison.

Changes

Stackdriver Source Location Type Fix

Layer / File(s) Summary
Variable type correction
plugins/out_stackdriver/stackdriver.c
source_location_line type changed from long to int64_t in stackdriver_format.

Gzip Header Magic-Byte Decode

Layer / File(s) Summary
Little-endian magic-byte check
src/flb_gzip.c
The gzip magic-number check now uses read_le16(...) before comparison, and the failure log prints the decoded value.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the two main fixes: the out_stackdriver line type change and the gzip magic check endian fix.
✨ 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 out_stackdriver-fix-int64-build

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.

The gzip header magic was memcpy'd into a uint16_t and compared
against 0x8B1F, which only holds on little endian hosts. On big
endian targets (s390x) a valid stream was rejected with
'invalid magic bytes : 1f8b'. Read the field with read_le16() so
the comparison works regardless of host byte order.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@edsiper
edsiper requested a review from cosmo0920 as a code owner July 4, 2026 05:04
@edsiper edsiper changed the title out_stackdriver: use int64_t for source_location_line build fixes: out_stackdriver int64_t line var, gzip endian-safe magic check Jul 4, 2026
@edsiper
edsiper merged commit a1e05fc into master Jul 4, 2026
90 of 92 checks passed
@edsiper
edsiper deleted the out_stackdriver-fix-int64-build branch July 4, 2026 06:26
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.

2 participants