FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[codex] fix windows events row rendering crashes by ktsaou · Pull Request #22872 · netdata/netdata · GitHub

[codex] fix windows events row rendering crashes - #22872

Merged
ktsaou merged 1 commit into
netdata:masterfrom
ktsaou:codex/fix-windows-events-variant-crash
Jun 26, 2026
Merged

[codex] fix windows events row rendering crashes#22872
ktsaou merged 1 commit into
netdata:masterfrom
ktsaou:codex/fix-windows-events-variant-crash

Conversation

ktsaou commented Jun 26, 2026
edited
Loading

Copy link
Copy Markdown
Member

Summary

Fix likely crash paths in windows-events.plugin row rendering for events that contain unusual or malformed Windows Event API payloads.

The report was clarified after the draft PR was opened: the observed crash was not an FTS query. It happened with a plain data=true query over a specific timeframe, and histogram traversal worked while viewing the rows did not. That points to lazy row rendering, where the dynamic Message and XML columns format the saved Windows event handle during facets_report().

Root cause candidates addressed

  • Plain data=true row rendering formatted XML and then separately formatted the event message for every returned row. The row renderer now formats XML once and uses the existing RenderingInfo/Message extraction path for the visible message.
  • EvtFormatMessage_utf16() trusted BufferUsed enough to write dst->data[size - 1]. It now treats zero BufferUsed as a formatting failure.
  • System event fields are rendered from external Windows EVT_VARIANT payloads, but the code indexed them without validating the returned property count and used production fatal_assert() checks for exact types. Rows now validate the system property count and degrade unexpected types to defaults instead of aborting.
  • Provider metadata loading used the same strict field accessors and assumed scalar/object-array/name property shapes. It now rejects array-valued scalar fields, validates metadata buffers and handles, and compacts only usable metadata entries.
  • Provider metadata handle refcounts were mutated partly outside the provider-cache spinlock while idle handles can be deleted under that lock. Refcount transitions now use the same lock discipline.
  • Channel config property failures could leave stale variant metadata for later source categorization reads. Property fetches now reset result metadata before reuse.
  • Source scanning could jump to cleanup while holding the scan lock or with an opened log handle. Cleanup now closes/unlocks consistently on early exits.
  • Lazy XML/message extraction had slice-bound order issues and unbounded strstr() / strchr() searches. It now bounds-checks before dereferencing and searches only within the formatted XML slice.
  • The FTS event-data renderer cast ANSI variants to UTF-16. It now converts EvtVarTypeAnsiString through any_to_utf16(CP_ACP, ...).
  • The FTS array branch treated binary and event-handle arrays as readable even though the local Windows SDK exposes no BinaryArr or EvtHandleArr union member. Those unsupported array forms are now skipped; scalar binary and event-handle rendering remains unchanged.
  • Array-valued variant flattening now checks the relevant array base pointer before indexing when Count > 0.

PR review follow-up

cubic identified four valid hardening issues on the previous commit. This update addresses them by:

  • using (end - p) >= needle_len in the bounded XML slice scan;
  • preserving the previous WEVT_VARIANT buffer size when computing resize growth;
  • rejecting array-valued variants in provider platform string checks;
  • rejecting array-valued variants in provider metadata name extraction.

Changes

  • Make lazy data=true row rendering avoid the redundant EvtFormatMessageEvent call after XML rendering.
  • Add non-fatal checked EVT_VARIANT accessors for Windows event/system/provider data.
  • Validate rendered system property counts before indexing EvtSystem* fields.
  • Harden provider metadata property, object-array, and handle-lifetime handling.
  • Harden channel source scanning cleanup and channel config property reuse.
  • Bound lazy XML extraction to the provided XML slice.
  • Decode scalar and array EvtVarTypeAnsiString with the existing Windows ANSI conversion path.
  • Keep binary variant direct writes NUL-terminated, skip unsupported binary/handle array shapes, and guard array base pointers before indexing.

Validation

  • Full compile of all src/collectors/windows-events.plugin/*.c translation units present in build-cygwin-MSYS/compile_commands.json passed with no diagnostics.
  • git diff --check and git diff --cached --check passed, aside from local CRLF warnings emitted by Git on Windows.
  • Same-failure search confirmed no remaining ANSI-to-UTF16 casts, strict external-variant type assertions, direct provider-name/provider-handle union reads, XML slice-scan pointer arithmetic, or lazy XML bound-order issues under src/collectors/windows-events.plugin.
  • Static array-index search confirmed the remaining *Arr[i] reads are confined to evt_variant_to_buffer() behind the new per-type null-base guard.
  • Select-String around EvtVarTypeBinary and EvtVarTypeEvtHandle confirmed array branches skip unsupported shapes while scalar branches still render them.
  • Lazy-row search confirmed wevt_lazy_loading_event_and_xml() no longer calls EvtFormatMessage_Event_utf8(); that call remains only in the FTS preload path.
  • .agents/sow/audit.sh active-SOW checks and sensitive-data scan passed; the audit still reports pre-existing legacy SOW references in unrelated SNMP trap spec research files.

No reproducing Windows host or event payload was available for runtime verification.

References:

github-actions Bot added the area/collectors Everything related to data collection label Jun 26, 2026

cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant UI as Windows Event Log
    participant Plugin as windows-events.plugin
    participant FTS as Full-Text Search Preload
    participant Variant as evt_variant_to_buffer()
    participant AnsiHelper as append_ansi() NEW
    participant BinaryHelper as append_binary()
    participant GuidHelper as append_guid()
    participant SystimeHelper as append_systime()
    participant FiletimeHelper as append_filetime_value()
    participant SidHelper as append_sid()
    participant CP as any_to_utf16(CP_ACP)

    Note over UI,SidHelper: Event Data Variant Flattening Flow

    UI->>Plugin: Event with EvtVarTypeAnsiString payload
    Plugin->>FTS: Preload event data for indexing
    FTS->>Variant: Call evt_variant_to_buffer()

    alt Type is EvtVarTypeAnsiString
        Variant->>Variant: Extract type mask (Type & EVT_VARIANT_TYPE_MASK)
        alt Array variant
            Variant->>AnsiHelper: Process each AnsiStringArr[i]
        else Scalar variant
            Variant->>AnsiHelper: Process AnsiStringVal
        end
        AnsiHelper->>AnsiHelper: Null/empty check
        AnsiHelper->>CP: Convert ANSI to UTF-16 via CP_ACP
        CP-->>AnsiHelper: Wide character buffer
        AnsiHelper->>Variant: Append converted string to output buffer
    else Type is EvtVarTypeBinary
        Variant->>BinaryHelper: Process BinaryVal + size
        BinaryHelper->>BinaryHelper: Validate bounds (size_t overflow check)
        BinaryHelper->>BinaryHelper: Render hex digits
        BinaryHelper->>BinaryHelper: NUL-terminate output
        BinaryHelper-->>Variant: Hex string in buffer
    else Type is EvtVarTypeGuid
        Variant->>GuidHelper: Process GuidVal
        alt Null pointer
            GuidHelper->>GuidHelper: Early return (defensive check)
        else Valid guid
            GuidHelper->>GuidHelper: Append formatted GUID
        end
    else Type is EvtVarTypeSysTime
        Variant->>SystimeHelper: Process SysTimeVal
        alt Null pointer
            SystimeHelper->>SystimeHelper: Early return
        else Valid systime
            SystimeHelper->>SystimeHelper: Format datetime
        end
    else Type is EvtVarTypeFileTime
        Variant->>FiletimeHelper: Process FileTimeVal
        alt Null pointer
            FiletimeHelper->>FiletimeHelper: Early return
        else Valid filetime
            FiletimeHelper->>FiletimeHelper: Convert via FileTimeToSystemTime
            FiletimeHelper->>SystimeHelper: Format as datetime
        end
    else Type is EvtVarTypeSid
        Variant->>SidHelper: Process SidVal
        alt Null pointer
            SidHelper->>SidHelper: Early return
        else Valid SID
            SidHelper->>SidHelper: Append SID string
        end
    else Type is EvtVarTypeBoolean (array)
        Variant->>Variant: Append "true"/"false" per element
    end

    Variant-->>FTS: Flattened event data string
    FTS-->>Plugin: Full-text search indexable content
Loading

Re-trigger cubic

ktsaou force-pushed the codex/fix-windows-events-variant-crash branch 2 times, most recently from 76e894b to d358b79 Compare June 26, 2026 05:14
ktsaou changed the title [codex] fix windows events variant decoding [codex] fix windows events row rendering crashes Jun 26, 2026
ktsaou force-pushed the codex/fix-windows-events-variant-crash branch from d358b79 to f147b21 Compare June 26, 2026 05:39

ktsaou commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

@cubic-dev-ai review this PR

cubic-dev-ai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@ktsaou I have started the AI code review. It will take a few minutes to complete.

cubic-dev-ai Bot left a comment
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

4 issues found across 6 files

Confidence score: 3/5

  • In src/collectors/windows-events.plugin/windows-events-providers.c, treating string-array variants as scalar strings during name/platform extraction can feed invalid memory into UTF-16 conversion and provider-type detection, which risks crashes or wrong provider classification at runtime — tighten variant-type checks to reject/handle arrays explicitly before conversion and detection.
  • In src/collectors/windows-events.plugin/windows-events-xml.c, the slice scan condition uses undefined pointer arithmetic (p + needle_len) that can step outside valid bounds, creating unpredictable matching behavior in XML parsing — rewrite the loop guard to (end - p) >= needle_len before merging.
  • In src/collectors/windows-events.plugin/windows-events-query.h, resetting v->size during cleanup in wevt_variant_resize() can undo growth history and cause extra realloc churn, which may degrade performance under sustained event load — preserve the previous size when computing the next allocation.
Architecture diagram
sequenceDiagram
    participant Client as Web Client
    participant API as REST API
    participant Plugin as Windows Events Plugin
    participant Renderer as Row Renderer
    participant Variant as EVT_VARIANT Accessor
    participant Provider as Provider Metadata Loader
    participant XMLParser as XML Parser
    participant WinAPI as Windows Event API

    Note over Client,WinAPI: Lazy row rendering for data=true queries

    Client->>API: GET /api/v1/data?data=true
    API->>Plugin: Query events for timeframe
    Plugin->>WinAPI: EvtRender(EvtRenderEventValues)
    WinAPI-->>Plugin: WEVT_VARIANT with system fields
    alt Insufficient system fields
        Plugin->>Plugin: Validate property_count >= EvtSystemPropertyIdEND
        Plugin-->>API: Return error
    else Valid system fields
        Plugin->>Variant: wevt_field_get_uint64() for EventRecordId
        Plugin->>Variant: wevt_field_get_string() for ProviderName
        Variant-->>Plugin: Degrade gracefully on type mismatch
        Plugin->>Provider: provider_get(uuid, name)
        Provider->>WinAPI: EvtGetPublisherMetadataProperty()
        alt Zero buffer used or empty metadata
            Provider->>Provider: Skip property loading
            Provider-->>Plugin: Return handle with WEVT_PLATFORM_UNKNOWN
        else Valid metadata
            Provider->>Provider: Validate object array handles
            Provider->>WinAPI: EvtGetObjectArrayProperty() for levels/tasks/opcodes
            alt Null handle or zero items
                Provider->>Provider: Skip array loading, compact list to 0 entries
            else Valid array
                Provider->>Provider: Use checked uint32 accessors for message IDs
                Provider->>Provider: wevt_field_get_string() for names
                Provider->>Provider: Compact only validated entries
            end
            Provider-->>Plugin: Return populated metadata handle
        end
        Plugin-->>API: Return event metadata
    end

    Note over Plugin,XMLParser: Lazy XML/Message on row rendering

    Client->>API: Request row rendering
    API->>Plugin: wevt_lazy_loading_event_and_xml()
    Plugin->>WinAPI: EvtFormatMessage(EvtFormatMessageXml)
    alt Zero buffer used
        Plugin->>Plugin: Treat as formatting failure
    else Valid XML
        WinAPI-->>Plugin: XML string in ops.xml
        Plugin->>XMLParser: buffer_extract_and_print_xml_with_cb()
        XMLParser->>XMLParser: find_string_in_slice() for Event/System nodes
        alt NULL slice or out-of-bounds search
            XMLParser-->>Plugin: Return false without crash
        else Valid nodes found
            XMLParser->>XMLParser: Bounds-check before memchr/strstr
            XMLParser-->>Plugin: Extracted message text
        end
        Note over Plugin: CHANGED: Skip redundant EvtFormatMessageEvent call
        Plugin->>Plugin: Set ops.event to empty
        Plugin->>Plugin: Mark row as rendered
    end

    Note over Variant,WinAPI: FTS variant rendering paths

    Plugin->>Variant: evt_variant_to_buffer() for FTS results
    alt Array branch (EVT_VARIANT_TYPE_ARRAY)
        alt EvtVarTypeAnsiString
            Variant->>Variant: append_ansi() with CP_ACP conversion
        else EvtVarTypeBinary or EvtVarTypeEvtHandle
            Variant->>Variant: CHANGED: Skip unsupported array shapes
        else Other types
            Variant->>Variant: Normal array rendering
        end
    else Scalar branch
        alt EvtVarTypeAnsiString
            Variant->>Variant: append_ansi() with CP_ACP conversion
        else EvtVarTypeBinary or EvtVarTypeEvtHandle
            Variant->>Variant: Direct NUL-terminated write
        else EvtVarTypeFileTime
            Variant->>Variant: append_filetime_value() from ULONGLONG
        else EvtVarTypeSysTime or EvtVarTypeSid
            Variant->>Variant: Render with NULL pointer check
        else EvtVarTypeNull
            Variant->>Variant: Skip rendering
        end
    end
    Variant-->>Plugin: Formatted buffer
    Plugin-->>API: FTS row data
    API-->>Client: Rendered response
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

ktsaou force-pushed the codex/fix-windows-events-variant-crash branch 2 times, most recently from 2ae2e6e to dcfe504 Compare June 26, 2026 06:29

ktsaou commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

@cubic-dev-ai please review again.

I made one final XML hardening pass after the previous push: the XML parser now checks remaining slice length before reading xml + 1, s + 3, or s + 4, matching the bounded pointer-arithmetic fix already applied to the XML slice search.

cubic-dev-ai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai please review again.

I made one final XML hardening pass after the previous push: the XML parser now checks remaining slice length before reading xml + 1, s + 3, or s + 4, matching the bounded pointer-arithmetic fix already applied to the XML slice search.

@ktsaou I have started the AI code review. It will take a few minutes to complete.

cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

ktsaou marked this pull request as ready for review June 26, 2026 07:05
ktsaou requested a review from thiagoftsm as a code owner June 26, 2026 07:05
ktsaou force-pushed the codex/fix-windows-events-variant-crash branch from dcfe504 to b6155c0 Compare June 26, 2026 07:14

ktsaou commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

@cubic-dev-ai please review again.

I made one performance-only follow-up after checking the PR impact: ANSI event-data conversion now uses a stack UTF-16 buffer for normal-sized strings and keeps the heap fallback for long strings, avoiding per-string heap churn in the FTS flattening path. The plain data=true lazy row path remains faster/neutral from the earlier change that avoids redundant event-message formatting.

cubic-dev-ai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai please review again.

I made one performance-only follow-up after checking the PR impact: ANSI event-data conversion now uses a stack UTF-16 buffer for normal-sized strings and keeps the heap fallback for long strings, avoiding per-string heap churn in the FTS flattening path. The plain data=true lazy row path remains faster/neutral from the earlier change that avoids redundant event-message formatting.

@ktsaou I have started the AI code review. It will take a few minutes to complete.

cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant UI as HTTP API / UI
    participant Collector as Windows Events Collector
    participant RowRender as Row Renderer (lazy)
    participant EvtQuery as Windows Event Query Engine
    participant EvtVar as EVT_VARIANT Accessor
    participant Provider as Provider Cache
    participant Source as Source Scanner
    participant WinAPI as Windows Event API
    participant XMLParser as XML Parser

    Note over Collector,WinAPI: Core data flow for event row rendering

    UI->>Collector: Request `data=true` rows (plain query)
    Collector->>Collector: Allocate WEVT_VARIANT for system fields
    Collector->>EvtQuery: wEvtRender() - render event values
    EvtQuery->>WinAPI: EvtRender(EvtRenderEventValues)
    WinAPI-->>EvtQuery: Returns EVT_VARIANT array + property_count

    Note over EvtQuery: Validate: bytes_used > 0, property_count sanity<br/>(NEW: reject zero-length buffers, OOB writes)
    EvtQuery-->>Collector: Success with property count

    Collector->>EvtQuery: wevt_get_next_event_one()
    EvtQuery->>EvtVar: Access EvtSystem* fields via checked getters
    Note over EvtVar: NEW: All field accessors check type & reject arrays<br/>(no more fatal_assert on type mismatch)
    EvtVar-->>EvtQuery: System event metadata (id, timestamp, provider, etc.)

    EvtQuery->>Provider: provider_get() with provider UUID + name
    Provider->>WinAPI: EvtOpenPublisherMetadata()
    WinAPI-->>Provider: Metadata handle

    Note over Provider: NEW: handle refcount operations under spinlock<br/>Reject zero BufferUsed, validate array/object property counts
    Provider-->>EvtQuery: Provider metadata handle

    EvtQuery-->>Collector: Structured event struct

    Note over Collector,RowRender: Lazy rendering triggered by FACET_ROW display

    Collector->>RowRender: wevt_lazy_loading_event_and_xml()
    RowRender->>RowRender: Format XML via EvtFormatMessage_Xml_utf8()
    RowRender->>RowRender: CHANGED: Skip EvtFormatMessage_Event_utf8()<br/>Empty the event message buffer instead
    Note over RowRender: Previously did both XML + message per row<br/>Now: XML once, message extracted from RenderingInfo
    RowRender-->>Collector: Rendered row data

    Collector->>XMLParser: buffer_extract_and_print_xml_with_cb()
    XMLParser->>XMLParser: Parse slice-bounded XML
    Note over XMLParser: NEW: All string searches use find_string_in_slice()<br/>with explicit end-pointer bounds, no unbounded strstr()

    alt Array-valued EVT_VARIANT
        Collector->>EvtVar: evt_variant_to_buffer() - array branch
        Note over EvtVar: NEW: Check array base pointer before indexing<br/>(e.g., ev->StringArr, ev->UInt32Arr)
        alt Unsupported array types (Binary, EvtHandle)
            EvtVar->>EvtVar: Skip rendering entirely
        else Supported types
            EvtVar->>EvtVar: Convert each element<br/>NEW: ANSI strings via any_to_utf16(CP_ACP)
        end
    else Scalar EVT_VARIANT
        Collector->>EvtVar: evt_variant_to_buffer() - scalar branch
        Note over EvtVar: NEW: Added FileTime, SysTime, Sid scalar rendering<br/>Previously only handled via array path
    end

    EvtVar-->>Collector: Rendered variant as buffer string
    Collector-->>UI: Rendered row JSON

    Note over Source,WinAPI: Background source scanning (parallel path)

    Source->>Source: wevt_sources_scan()
    Source->>Source: Acquire spinlock (trylock)
    Source->>WinAPI: EvtOpenChannelEnum()
    WinAPI-->>Source: Channel enumeration handle

    loop For each channel
        Source->>WinAPI: EvtGetChannelConfigProperty() - channel type
        Source->>WinAPI: EvtGetChannelConfigProperty() - classic flag
        Source->>WinAPI: EvtGetChannelConfigProperty() - owning publisher
        Source->>WinAPI: EvtGetChannelConfigProperty() - enabled flag
        Source->>WinAPI: EvtGetChannelConfigProperty() - retention/auto backup

        Note over Source,NEW: Each property fetch resets used/count before reuse<br/>CHANGED: Reject zero-length results, validate via checked getters
        Source->>Source: categorize_channel() - build WEVT_SOURCE_TYPE flags
    end

    alt Early exit (channel enum failure)
        Source->>Source: Close log handle if open, unlock spinlock
    else Completion
        Source->>WinAPI: wevt_closelog6()
        Source->>WinAPI: EvtClose(channelEnum)
        Source->>Source: Release lock, cleanup variant
    end

    Note over Source: NEW: Always close log handle before early cleanup<br/>Avoid stale spinlock holder / open handle leaks

    Source-->>Collector: Updated source configuration
Loading

Re-trigger cubic

ktsaou force-pushed the codex/fix-windows-events-variant-crash branch from b6155c0 to b5967eb Compare June 26, 2026 11:08

ktsaou commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

@cubic-dev-ai please review again.

I addressed the GitHub Advanced Security / Sonar comment on the ANSI conversion fast path: append_ansi() no longer calls strlen() on the Windows-provided string. It now scans only up to the stack buffer capacity before using the stack conversion path, and keeps the existing heap fallback for longer strings.

cubic-dev-ai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai please review again.

I addressed the GitHub Advanced Security / Sonar comment on the ANSI conversion fast path: append_ansi() no longer calls strlen() on the Windows-provided string. It now scans only up to the stack buffer capacity before using the stack conversion path, and keeps the existing heap fallback for longer strings.

@ktsaou I have started the AI code review. It will take a few minutes to complete.

cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Client as Win Event Plugin (UI)
    participant Lazy as Lazy Row Renderer
    participant Render as wEvtRender
    participant Variant as EVT_VARIANT Accessors
    participant Provider as Provider Meta Cache
    participant Source as Source Scanner
    participant XML as XML Parser

    Note over Client,XML: Core flows affected by this PR

    Client->>Lazy: data=true query (row rendering)
    Lazy->>Render: wEvtRender() for XML
    Render->>Variant: wevt_field_get_string() for provider name
    Variant-->>Render: validated string or NULL
    Render-->>Lazy: XML buffer
    Lazy->>XML: buffer_extract_and_print_xml_with_cb()
    XML->>XML: find_string_in_slice() (bounded search)
    XML-->>Lazy: extracted message text
    Note over Lazy: CHANGED: No separate EvtFormatMessage_Event call<br/>Uses XML extraction for message

    alt Provider metadata lookup
        Lazy->>Provider: provider_get() with UUID/name
        Provider->>Provider: wevt_field_get_string_checked() for owning publisher
        Provider->>Provider: provider_detect_platform() - wevt_field_get_uint16_checked()
        Provider->>Provider: provider_load_list() - compact only valid entries
        Note over Provider: wevt_field_get_evt_handle() rejects arrays
        Provider-->>Lazy: PROVIDER_META_HANDLE (or NULL)
    end

    Lazy->>Lazy: wevt_lazy_loading_event_and_xml()
    Note over Lazy: Renders XML once, sets event message to empty

    alt System fields extraction
        Lazy->>Variant: wevt_field_get_uint64() (record ID)
        Lazy->>Variant: wevt_field_get_uint16() (event ID)
        Lazy->>Variant: wevt_field_get_filetime_to_ns() (timestamp)
        Lazy->>Variant: wevt_field_get_sid() (user)
        Lazy->>Variant: wevt_field_get_string_utf8() (message)
        Note over Variant: All use _checked variants that return false on type mismatch
    end

    alt Array variant rendering
        Client->>Variant: evt_variant_to_buffer() with array flag
        Variant->>Variant: Check array base pointer (ev->StringArr, etc.)
        Variant->>Variant: append_ansi() for EvtVarTypeAnsiString (CHANGED: CP_ACP conversion)
        Variant->>Variant: append_binary() - guard oversize & null-terminate
        Note over Variant: Binary/EvtHandle arrays: return without rendering
        Variant-->>Client: formatted buffer
    end

    Source->>Source: wevt_sources_scan()
    Source->>Provider: ndEvtGetChannelConfigProperty() - reset metadata before each call
    Provider-->>Source: channel properties (validated types)
    Source->>Source: categorize_channel() - uses wevt_field_get_bool_checked()/uint32_checked()
    Note over Source: Safe cleanup: close log & unlock even on early exit

    alt Provider handle refcount
        Provider->>Provider: provider_dup() - CHANGED: locked under spinlock
        Provider->>Provider: provider_release() - CHANGED: full lock discipline
        Note over Provider: Handles now use same lock for inc/dec
    end
Loading

Re-trigger cubic

ktsaou merged commit 5a71b1c into netdata:master Jun 26, 2026
156 of 157 checks passed

Copy link
Copy Markdown

stelfrag pushed a commit to stelfrag/netdata that referenced this pull request Jul 12, 2026
stelfrag mentioned this pull request Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL