Skip to content

Commit ef64a5d

Browse files
bmehta001Copilot
andcommitted
Merge main to preserve decoder coverage and restore leak-analysis CI
Resolve the decoder-test includes without dropping either branch's regressions. Brace the compact-SKU logging conditional so disabling logging does not trigger C4390. Aggregate completed Dr. Memory process reports so forked Linux tests retain leak accounting instead of failing report discovery. Files updated beyond the main merge: tests/unittests/PayloadDecoderTests.cpp; lib/pal/desktop/WindowsDesktopSystemInformationImpl.cpp; .github/scripts/run-drmemory.ps1; .github/workflows/memory-leak-analysis.yml; tests/memory-leak-analysis/run-drmemory-tests.ps1; docs/maintainer-onboarding.md. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f81706eb-e23d-4739-a41b-8851e2c3653a
2 parents 19a503e + eb68c2d commit ef64a5d

59 files changed

Lines changed: 1503 additions & 221 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/scripts/run-drmemory.ps1‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,25 @@ $ErrorActionPreference = "Stop"
2727
function Get-LeakCount {
2828
param(
2929
[Parameter(Mandatory = $true)]
30-
[string]$Results,
30+
[string[]]$Results,
3131

3232
[Parameter(Mandatory = $true)]
3333
[string]$Category
3434
)
3535

3636
$escapedCategory = [regex]::Escape($Category)
3737
$pattern = "(?m)^\s*(?:~~Dr\.M~~\s+)?([\d,]+) unique,\s+([\d,]+) total,\s+([\d,]+) byte\(s\) of $escapedCategory\r?$"
38-
$match = [regex]::Match($Results, $pattern)
39-
if (-not $match.Success) {
40-
throw "Dr. Memory results do not contain the '$Category' summary."
41-
}
42-
43-
return @{
44-
Unique = [int64]($match.Groups[1].Value -replace ",", "")
45-
Total = [int64]($match.Groups[2].Value -replace ",", "")
46-
Bytes = [int64]($match.Groups[3].Value -replace ",", "")
38+
$counts = @{ Unique = [int64]0; Total = [int64]0; Bytes = [int64]0 }
39+
foreach ($result in $Results) {
40+
$match = [regex]::Match($result, $pattern)
41+
if (-not $match.Success) {
42+
throw "Dr. Memory results do not contain the '$Category' summary."
43+
}
44+
$counts.Unique += [int64]($match.Groups[1].Value -replace ",", "")
45+
$counts.Total += [int64]($match.Groups[2].Value -replace ",", "")
46+
$counts.Bytes += [int64]($match.Groups[3].Value -replace ",", "")
4747
}
48+
return $counts
4849
}
4950

5051
$resolvedDrMemoryPath = (Resolve-Path -LiteralPath $DrMemoryPath).Path
@@ -70,11 +71,12 @@ $resultFiles = @(Get-ChildItem -LiteralPath $scenarioDirectory -Filter results.t
7071
$resultFiles = @($resultFiles | Where-Object {
7172
Select-String -LiteralPath $_.FullName -Pattern '^(?:NO )?ERRORS FOUND:\r?$' -Quiet
7273
})
73-
if ($resultFiles.Count -ne 1) {
74-
throw "Expected one completed Dr. Memory results.txt for $Scenario, found $($resultFiles.Count)."
74+
if ($resultFiles.Count -eq 0) {
75+
throw "Expected at least one completed Dr. Memory results.txt for $Scenario, found none."
7576
}
7677

77-
$results = Get-Content -LiteralPath $resultFiles[0].FullName -Raw
78+
# Forked tests produce separate reports; include every completed process.
79+
$results = @($resultFiles | ForEach-Object { Get-Content -LiteralPath $_.FullName -Raw })
7880
$leaks = Get-LeakCount -Results $results -Category "leak(s)"
7981
$possibleLeaks = Get-LeakCount -Results $results -Category "possible leak(s)"
8082
$reachable = Get-LeakCount -Results $results -Category "still-reachable allocation(s)"

‎.github/workflows/build-android.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ jobs:
109109
run: |
110110
.\gradlew.bat maesdk:test
111111
working-directory: lib\android_build
112+
- name: Gradle Build without native device-ID collection
113+
run: |
114+
.\gradlew.bat maesdk:assembleDebug app:assembleDebug -PMATSDK_ENABLE_DEVICE_ID=OFF
115+
working-directory: lib\android_build
112116
- name: Upload Reports
113117
if: failure()
114118
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2

‎.github/workflows/build-posix-latest.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,37 @@ jobs:
5050
- name: Test ${{ matrix.os }} ${{ matrix.config }}
5151
run: ./build-tests.sh ${{ matrix.config }}
5252

53+
device-id-optout:
54+
name: Device-ID opt-out (${{ matrix.os }})
55+
runs-on: ${{ matrix.os }}
56+
env:
57+
CMAKE_POLICY_VERSION_MINIMUM: "3.5"
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
os: [ubuntu-latest, macOS-latest, windows-2022]
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
65+
- name: Initialize googletest
66+
run: git submodule update --init --depth=1 third_party/googletest
67+
- name: Test Linux/macOS without native device-ID collection
68+
if: runner.os != 'Windows'
69+
env:
70+
CMAKE_OPTS: -DMATSDK_ENABLE_DEVICE_ID=OFF
71+
run: ./build-tests.sh debug
72+
- name: setup-msbuild
73+
if: runner.os == 'Windows'
74+
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0
75+
with:
76+
vs-version: '[17,)'
77+
- name: Test Windows without native device-ID collection
78+
if: runner.os == 'Windows'
79+
shell: cmd
80+
run: build-tests.cmd x64 Debug "tests\device-id-optout.props" WinHTTP
81+
- name: Verify vcpkg feature mapping
82+
run: cmake -P tests/vcpkg/device-id-feature-tests.cmake
83+
5384
public-headers:
5485
name: Public header gate (GCC/Clang)
5586
runs-on: ubuntu-latest

‎.github/workflows/memory-leak-analysis.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- main
1010
paths:
1111
- .github/scripts/run-drmemory.ps1
12+
- tests/memory-leak-analysis/**
1213
- .github/memory-leak-baseline.csv
1314
- .github/workflows/memory-leak-analysis.yml
1415
- CMakeLists.txt
@@ -28,6 +29,7 @@ on:
2829
- main
2930
paths:
3031
- .github/scripts/run-drmemory.ps1
32+
- tests/memory-leak-analysis/**
3133
- .github/memory-leak-baseline.csv
3234
- .github/workflows/memory-leak-analysis.yml
3335

@@ -51,6 +53,10 @@ jobs:
5153
- name: Checkout
5254
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
5355

56+
- name: Test Dr. Memory report parsing
57+
shell: pwsh
58+
run: ./tests/memory-leak-analysis/run-drmemory-tests.ps1
59+
5460
- name: Initialize googletest
5561
run: git submodule update --init --depth=1 third_party/googletest
5662

@@ -170,6 +176,10 @@ jobs:
170176
- name: Checkout
171177
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
172178

179+
- name: Test Dr. Memory report parsing
180+
shell: pwsh
181+
run: ./tests/memory-leak-analysis/run-drmemory-tests.ps1
182+
173183
- name: Initialize googletest
174184
run: git submodule update --init --depth=1 third_party/googletest
175185

‎CMakeLists.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ if(MATSDK_DISABLE_LOGGING)
120120
target_compile_definitions(matsdk_internal_config INTERFACE
121121
MATSDK_DISABLE_LOGGING)
122122
endif()
123+
if(NOT MATSDK_ENABLE_DEVICE_ID)
124+
target_compile_definitions(matsdk_internal_config INTERFACE
125+
MATSDK_DISABLE_DEVICE_ID)
126+
endif()
123127

124128
option(GCC5_CXX11_ABI_WORKAROUND "Workaround: Use legacy C++11 ABI (for GCC 5 compatibility)" OFF)
125129
if(GCC5_CXX11_ABI_WORKAROUND)

‎cmake/MatsdkOptions.cmake‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ option(MATSDK_USE_WININET
4646
"Use WinInet instead of WinHTTP as the Win32 desktop HTTP client" OFF)
4747
option(MATSDK_DISABLE_LOGGING
4848
"Compile internal SDK logging out" OFF)
49+
option(MATSDK_ENABLE_DEVICE_ID
50+
"Collect a device ID using the SDK's platform-specific implementation" ON)
4951

5052
set(_matsdk_android_http_client_predefined OFF)
5153
if(DEFINED MATSDK_ANDROID_HTTP_CLIENT)

‎docs/CsProtocol-decoding.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,23 @@ Please refer to usage examples:
2828

2929
* EventDecoderListener.cpp [EventDecoderListener::DecodeBuffer](../tests/functests/EventDecoderListener.cpp) for HTTP(s) request - Package of Records decoding
3030
* APITest.cpp [UTC_Callback_Test](../tests/functests/APITest.cpp) for Common Schema Record decoding
31+
32+
## Decoder input limits
33+
34+
Diagnostic request decoding rejects inputs larger than 64 MiB, including
35+
compressed input and the inflated output. Inflation uses a fixed-size work
36+
buffer and stops before growing the output beyond that limit; it does not
37+
estimate output size from a presumed compression ratio.
38+
39+
Binary container counts must fit the remaining encoded input (at least one
40+
byte per sequence element or two bytes per map entry). Impossible counts are
41+
rejected before generated readers allocate their containers; no separate
42+
fixed element-count or record-count limit is imposed.
43+
Record-boundary scanning reads the request in place and copies only each
44+
individual record, so scanning and input copying are linear in request size.
45+
Decoding failure returns `false` rather than reporting a partial request as
46+
success; partial inflation output
47+
must not be used after a failed call.
48+
49+
These diagnostic limits do not change the event submission API or its
50+
configured serialized-event size policy.

‎docs/PAL.md‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,61 @@
5959

6060
## Remote configuration (ECS client)
6161

62+
## Device-ID collection
63+
64+
`MATSDK_ENABLE_DEVICE_ID` defaults to `ON`. Configure with
65+
`-DMATSDK_ENABLE_DEVICE_ID=OFF` to compile out the SDK's native device-ID
66+
collectors, including machine-ID reads, fallback shell commands, adapter
67+
queries, host UUIDs, and vendor/Android identifiers. Other system and device
68+
metadata remain enabled. The macOS build also stops linking the ID-specific
69+
IOKit framework; dependencies still used by other features remain.
70+
71+
Without a supplied ID, `DeviceInfo.Id` is omitted rather than replaced with a
72+
placeholder. Applications can still supply their own ID through
73+
`ISemanticContext::SetDeviceId`; registration does not overwrite it with an
74+
empty automatically collected ID. Android's Java bridge consults the native
75+
build setting before accessing `ANDROID_ID`; use the matching Java bridge
76+
sources with the native SDK. For Android Gradle builds, pass
77+
`-PMATSDK_ENABLE_DEVICE_ID=OFF` to apply the setting to both the SDK AAR and
78+
the test application. The Gradle property takes precedence over the
79+
`MATSDK_ENABLE_DEVICE_ID` environment variable; both default to `ON` when
80+
unspecified.
81+
82+
This option does not disable session/SDK identifiers or control device IDs
83+
added independently by the operating system's UTC telemetry pipeline.
84+
85+
## Targeted input safeguards
86+
87+
The SDK bounds the command-line input involved in initialization and buffered
88+
HTTP responses. It does not impose a blanket metadata limit on system,
89+
device, application, or network-provider strings, additional limits on
90+
OS-reported buffer sizes, or a size limit on persisted session files.
91+
92+
| Input | Limit | Oversize behavior |
93+
| --- | --- | --- |
94+
| POSIX application identifier | 4 KiB, stopping at the first NUL in `/proc/self/cmdline` | Truncate the executable name; never collect arguments or run a regex |
95+
| HTTP response body | 16 MiB | Fail the request rather than retain an oversized response |
96+
| HTTP response headers | 64 KiB | Fail the request rather than retain oversized headers |
97+
98+
POSIX OS release values use exact line-key matching rather than recursive
99+
regular expressions. Curl response headers are also parsed without regex.
100+
Command-line truncation preserves UTF-8 boundaries. Other metadata is not
101+
truncated by these safeguards. Session files retain the existing platform
102+
text-read behavior; session parsing accepts both LF and CRLF line endings.
103+
The header budget includes framing for native raw headers or a minimum
104+
four-byte allowance per name/value pair. Windows native queries measure raw
105+
UTF-16/ANSI buffer bytes; WinRT conservatively budgets up to three UTF-8 bytes
106+
per UTF-16 unit. Android counts JNI modified UTF-8 bytes without allocating
107+
encoded strings, including two bytes for NUL and three per surrogate, before
108+
JNI additionally checks their encoded byte sizes. OS networking frameworks may
109+
have their own internal limits; the SDK limits its own copies and streaming
110+
body reads.
111+
112+
Caller-provided events retain the existing configured serialized-event,
113+
upload, and offline-cache size policies; no new per-property limit is applied.
114+
See [decoder limits](CsProtocol-decoding.md#decoder-input-limits) for the
115+
separate diagnostic decoding budget.
116+
62117
## Bandwidth manager (Resource manager)
63118

64119
- Get available bandwidth

‎docs/building-with-vcpkg.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,46 @@ project's `vcpkg.json`:
5757

5858
## Platform-Specific Instructions
5959

60+
### Disabling SDK device-ID collection
61+
62+
The in-repo overlay port has a default-enabled `device-id` feature, mapped to
63+
the default-on CMake option `MATSDK_ENABLE_DEVICE_ID`. To supply your own
64+
`DeviceInfo.Id` without running the SDK's native collectors, omit that feature
65+
and explicitly retain the other features you need:
66+
67+
```json
68+
{
69+
"dependencies": [
70+
{
71+
"name": "cpp-client-telemetry",
72+
"default-features": false,
73+
"features": ["curl-openssl", "system-sqlite"]
74+
}
75+
]
76+
}
77+
```
78+
79+
For classic mode:
80+
81+
```console
82+
vcpkg install "cpp-client-telemetry[core,curl-openssl,system-sqlite]" --overlay-ports=tools/ports
83+
```
84+
85+
`curl-openssl` affects Linux only; Android still defaults to Java transport.
86+
`[core,...]` and `default-features: false` drop **all** defaults, including
87+
`device-id`. Add `device-id` explicitly when combining non-default features
88+
but wanting to retain native ID collection.
89+
90+
vcpkg features are additive across the dependency graph: another dependency
91+
requesting `device-id` (or the default features) re-enables collection. Ensure
92+
all requests for this port agree when opting out.
93+
94+
The official registry requires a port update pointing to an SDK release
95+
containing this option; existing registry versions do not expose the feature.
96+
Until then, use this repository's overlay port and source checkout. The port
97+
rejects an opt-out against an older SDK rather than silently collecting an ID.
98+
For direct CMake builds, use `-DMATSDK_ENABLE_DEVICE_ID=OFF`.
99+
60100
### Windows
61101

62102
```powershell

‎docs/embedding-with-cmake.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Set it explicitly to `ON` in consumer CI to test new toolchains strictly.
2929
Set `MATSDK_DISABLE_LOGGING=ON` to compile the SDK's internal diagnostic
3030
logging out. This does not disable telemetry event collection or upload.
3131

32+
Set `MATSDK_ENABLE_DEVICE_ID=OFF` before adding the SDK to compile out native
33+
device-ID collection while retaining other metadata. It defaults to `ON`.
34+
Applications can still set their own ID through `ISemanticContext::SetDeviceId`;
35+
without one, `DeviceInfo.Id` is omitted. See [device-ID collection](PAL.md#device-id-collection)
36+
for platform details and the distinction from session/SDK identifiers.
37+
3238
## SQLite and zlib providers
3339

3440
Source builds can select dependency modes without patching 1DS sources:

0 commit comments

Comments
 (0)