Skip to content

Conversation

@stelfrag
Copy link
Collaborator

@stelfrag stelfrag commented Dec 1, 2025

Summary
  • Change sensor initialization to handle COM setup in the sensor thread

Summary by cubic

Moved COM and Sensor API initialization to the sensors thread to respect COM’s per-thread model and prevent initialization errors. This stabilizes Windows sensors collection and ensures proper cleanup.

  • Bug Fixes
    • Initialize COM in netdata_sensors_monitor; handle RPC_E_CHANGED_MODE gracefully.
    • Create ISensorManager in the thread; release it and call CoUninitialize on exit.
    • Remove COM/SensorManager setup from initialize(); thread now owns pSensorManager.
    • Simplify cleanup: main path only joins the thread; no extra COM teardown.

Written for commit 2b45c4f. Summary will update automatically on new commits.

@github-actions github-actions bot added area/collectors Everything related to data collection collectors/windows labels Dec 1, 2025
@stelfrag stelfrag marked this pull request as ready for review December 1, 2025 14:40
@stelfrag stelfrag requested a review from thiagoftsm as a code owner December 1, 2025 14:40
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/collectors/windows.plugin/GetSensors.c">

<violation number="1" location="src/collectors/windows.plugin/GetSensors.c:635">
P2: `CoUninitialize()` is invoked even when this thread never successfully called `CoInitializeEx()` (e.g., when it returned `RPC_E_CHANGED_MODE`), which can unbalance COM initialization and break subsequent COM calls on the sensor thread.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Copy link
Contributor

@thiagoftsm thiagoftsm left a comment

Choose a reason for hiding this comment

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

After last commits, all 11 sensors on my laptop are having charts. LGTM!

@stelfrag stelfrag merged commit a87d38e into netdata:master Dec 1, 2025
118 checks passed
@stelfrag stelfrag deleted the fix_get_sensors branch December 1, 2025 19:14
@stelfrag stelfrag mentioned this pull request Dec 1, 2025
stelfrag added a commit to stelfrag/netdata that referenced this pull request Dec 1, 2025
* Chaneg sensor initialization to handle COM setup in the sensor thread

* Fix COM initialization handling in sensor thread

(cherry picked from commit a87d38e)
Ferroin pushed a commit that referenced this pull request Dec 3, 2025
* Chaneg sensor initialization to handle COM setup in the sensor thread

* Fix COM initialization handling in sensor thread

(cherry picked from commit a87d38e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/collectors Everything related to data collection collectors/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants