Skip to content

in_windows_exporter_metrics: Plug bitwise glitches on 32bit oses#11940

Merged
edsiper merged 3 commits into
masterfrom
cosmo0920-plug-bitwise-glitches-on-32bit-oses
Jun 12, 2026
Merged

in_windows_exporter_metrics: Plug bitwise glitches on 32bit oses#11940
edsiper merged 3 commits into
masterfrom
cosmo0920-plug-bitwise-glitches-on-32bit-oses

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

After long running investigations, we found that some of the bit width glitches on 32bit executable of Fluent Bit.
With this PR, we can retrieve prometheus compatible payloads from 32bit version of fluent-bit.exe.

Closes #10130.

I confirmed that it can retrieve from prometheus_exporter with curl(WebRequest-Invoke Cmdlet) on x86_64 Windows and 32bit/64bit exe pairs, and ARM64 Windows platforms.
32bit/64bit/arm64 executables of fluent-bit.exe are working as expected.


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.

  • 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
    • Fixed a memory allocation bug in text conversion to prevent incorrect buffer sizing and potential corruption.
    • Improved Windows metrics initialization to use per-context resources, with stronger cleanup on failures to avoid leaks.
    • Added more robust error detection and logging for query execution and iteration, improving troubleshooting and reliability.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 997bff2b-71df-443c-b107-b2ad0b3d090d

📥 Commits

Reviewing files that changed from the base of the PR and between eab065c and 900c4cc.

📒 Files selected for processing (1)
  • plugins/in_windows_exporter_metrics/we_wmi.c
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/in_windows_exporter_metrics/we_wmi.c

📝 Walkthrough

Walkthrough

Adds a per-context IWbemContext to the Windows exporter metrics input plugin, sets architecture VARIANTs in that context, passes it to ConnectServer/ExecQuery, fixes wide-string allocation, checks IWbemClassObject::Next HRESULTs, and releases the context on cleanup or failure.

Changes

WMI Context Management

Layer / File(s) Summary
WMI Context Type Definitions and Utilities
plugins/in_windows_exporter_metrics/we.h, plugins/in_windows_exporter_metrics/we_util.c
struct flb_we gains IWbemContext *wmi_context; we_convert_str() allocates wide buffer using sizeof(wchar_t).
WMI Context Initialization with Architecture Constraints
plugins/in_windows_exporter_metrics/we_wmi.c
wmi_coinitialize creates ctx->wmi_context, sets __ProviderArchitecture and __RequiredArchitecture VARIANTs, allocates namespace BSTR, passes context to ConnectServer, and releases context on failures.
WMI Query Execution with Context
plugins/in_windows_exporter_metrics/we_wmi.c
wmi_execute_query allocates BSTRs for WQL language/query and calls ExecQuery with ctx->wmi_context, freeing BSTRs afterward.
Query Enumeration Result Handling and Error Checking
plugins/in_windows_exporter_metrics/we_wmi.c
wmi_exec_query_fixed_val and wmi_exec_query check IWbemClassObject::Next HRESULTs, log on failure, and log debug when no items are returned.
WMI Context Lifecycle: Init and Cleanup
plugins/in_windows_exporter_metrics/we_wmi.c
we_wmi_init initializes ctx->wmi_context to NULL; wmi_cleanup releases and NULLs ctx->wmi_context.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

backport to v4.0.x, backport to v4.1.x

Suggested reviewers

  • edsiper
  • fujimotos
  • koleini

Poem

🐰 A rabbit hops through WMI's domain,
With context now bound, no endless refrain,
Architecture flags set snug and tight,
Queries run steady into the night,
Cleanup clears footprints—hopping light! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and uses technical jargon ('bitwise glitches') without clearly explaining what the PR fixes or changes. Consider a more descriptive title like 'Fix WMI context initialization for 32-bit Windows builds' that clearly indicates the primary change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR addresses the core issue #10130 by fixing WMI initialization bugs affecting 32-bit builds through proper context management and buffer allocation.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the reported 32-bit Windows issues: WMI context initialization, buffer allocation correction, and proper error handling.

✏️ 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-plug-bitwise-glitches-on-32bit-oses

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.

@cosmo0920 cosmo0920 added this to the Fluent Bit v5.0.8 milestone Jun 12, 2026

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

Copy link
Copy Markdown

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: cbe50ecb98

ℹ️ 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 plugins/in_windows_exporter_metrics/we_wmi.c
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@cosmo0920 cosmo0920 force-pushed the cosmo0920-plug-bitwise-glitches-on-32bit-oses branch from eab065c to 900c4cc Compare June 12, 2026 07:24
@edsiper edsiper merged commit 8e17223 into master Jun 12, 2026
63 of 64 checks passed
@edsiper edsiper deleted the cosmo0920-plug-bitwise-glitches-on-32bit-oses branch June 12, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport to v4.2.x docs-required Windows Bugs and requests about Windows platforms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input windows_exporter_metrics dosent work

2 participants