|
| 1 | +# Oracle known false positives — triage of the 2026-06-27 five-repo run |
| 2 | + |
| 3 | +Companion to [`oracle.md`](oracle.md). On 2026-06-27 the cross-tool oracle ran |
| 4 | +over five top-200-NuGet, general-purpose libraries — **Newtonsoft.Json, |
| 5 | +CsvHelper, serilog, NLog, protobuf-net** — diffing Own.NET against Infer# and |
| 6 | +CodeQL. This note records the triage of every **own-only** finding against the |
| 7 | +target's real source, so the verdicts are durable and the [FP |
| 8 | +baseline](../../corpus/oracle-fp-baseline.txt) that suppresses them on re-runs is |
| 9 | +auditable. |
| 10 | + |
| 11 | +Headline: across all five repos, **0 own-only findings came from the new |
| 12 | +owned-API recognition** (ADO `ExecuteReader`/`CreateCommand`, Xml/Json |
| 13 | +`.Create`/`.Parse`, Socket `Accept`) — those libraries don't use those APIs in a |
| 14 | +leaking shape, so the recognition extensions added **no noise on third-party |
| 15 | +code**. Every own-only finding is a disposable-field or event-subscription |
| 16 | +catch — Own.NET's differentiating niche, which the oracles' leak queries (local |
| 17 | +not-disposed) structurally cannot express. `Agree = 0` on all five for the same |
| 18 | +reason: we and the oracles occupy orthogonal niches. |
| 19 | + |
| 20 | +## Disposition summary |
| 21 | + |
| 22 | +20 own-only findings, triaged to ground truth: |
| 23 | + |
| 24 | +| disposition | count | what happens on re-run | |
| 25 | +|---|---:|---| |
| 26 | +| **Baselined FP** | 12 | moved to "Known FP (baselined)", out of the triage queue | |
| 27 | +| **Non-product (path filter)** | 2 | dropped by `--exclude-tests` (`unittest` rule) | |
| 28 | +| **True positive — kept visible** | 4 | stays in "Own.NET only" (real catch, oracle can't express) | |
| 29 | +| **True-but-benign — kept, baselined-as-sample** | 2 | (protobuf `assorted/` samples) baselined as non-product | |
| 30 | + |
| 31 | +The 12 baselined FPs + the 2 non-product-sample reals = 14 findings, covered by |
| 32 | +**13 rules** in `corpus/oracle-fp-baseline.txt` (the two `NetTranscoder` copies |
| 33 | +share one basename-keyed rule); the 2 test-base findings are the `--exclude-tests` |
| 34 | +drops; the 4 true positives are deliberately **not** suppressed. |
| 35 | + |
| 36 | +## Per-finding verdicts |
| 37 | + |
| 38 | +### NLog/NLog — 8 findings (disposable fields) |
| 39 | + |
| 40 | +| field / class | verdict | why | |
| 41 | +|---|---|---| |
| 42 | +| `_timeoutTimer` / TimeoutContinuation | **FP → baseline** | `Dispose()` → `StopTimer()` → `Timer.WaitForDispose()` (ext method) | |
| 43 | +| `_taskTimeoutTimer` / AsyncTaskTarget | **FP → baseline** | `Dispose(bool disposing)` → `Timer.WaitForDispose()` | |
| 44 | +| `_lazyWriterTimer` / AsyncTaskTarget | **FP → baseline** | `Dispose(bool disposing)` → `Timer.WaitForDispose()` | |
| 45 | +| `_lazyWriterTimer` / AsyncTargetWrapper | **FP → baseline** | `CloseTarget()` → `StopLazyWriterThread()` → `Timer.WaitForDispose()` | |
| 46 | +| `_flushTimer` / BufferingTargetWrapper | **FP → baseline** | `CloseTarget()` → `Timer.WaitForDispose()` | |
| 47 | +| `_xmlSource` / XmlParser | **true positive → keep** | never disposed (benign: a `CharEnumerator` over a `StringReader` over a string — no unmanaged resource) | |
| 48 | +| `_reusableFileWriteStream` / FileTarget | **true positive → keep** | never disposed (benign: `ReusableStreamCreator` over a `MemoryStream` — managed memory only) | |
| 49 | +| `_reusableBatchFileWriteStream` / FileTarget | **true positive → keep** | never disposed (same) | |
| 50 | + |
| 51 | +`WaitForDispose(this Timer, TimeSpan)` (NLog `Common/AsyncHelpers.cs`) really does |
| 52 | +dispose the timer (`Change(Infinite,Infinite)` then `Dispose()`). All five timer |
| 53 | +FPs route disposal through it, on a **local alias** of the field |
| 54 | +(`Interlocked.Exchange(ref _timer, null)` / `var t = _timer`), inside either a |
| 55 | +`Dispose(bool disposing)` override or a `CloseTarget()` lifecycle hook. The |
| 56 | +extractor's field-disposal scan only inspects the **top-level statements of the |
| 57 | +parameterless `Dispose()`** for a direct `field.Dispose()` — so it sees none of |
| 58 | +this. |
| 59 | + |
| 60 | +### protobuf-net/protobuf-net — 7 findings |
| 61 | + |
| 62 | +| location | verdict | why | |
| 63 | +|---|---|---| |
| 64 | +| `src/protobuf-net.Core/ProtoWriter.BufferWriter.cs` `_nullWriter` | **FP → baseline** | intentional null-object kept attached for pooled reuse; `Dispose()` comments *"don't cascade dispose to the null one"* | |
| 65 | +| `assorted/.../ProtoTranscoder.cs` `sync` (×2 copies) | **true-but-benign → baseline (non-product sample)** | `NetTranscoder` isn't `IDisposable`; one `ReaderWriterLockSlim` for app lifetime in a sample/extension tree | |
| 66 | +| `assorted/ProtoGen/CommandLineOptions.cs` `XsltMessageEncountered` | **FP → baseline** | self-subscription: publisher (`xsltOptions`) and the lambda are both owned by the same `CommandLineOptions`, co-lifetimed | |
| 67 | +| `assorted/SilverlightExtended/Page.xaml.cs` `timer` | **FP → baseline** | disposed by an enclosing `using (timer) { … }` the extractor missed (sample code) | |
| 68 | +| `src/BuildToolsUnitTests/AnalyzerTestBase.cs` `logging.Log` | **test noise → path filter** | xUnit fixture; per-test lifetime | |
| 69 | +| `src/BuildToolsUnitTests/GeneratorTestBase.cs` `logging.Log` | **test noise → path filter** | xUnit fixture; per-test lifetime | |
| 70 | + |
| 71 | +The two `BuildToolsUnitTests` findings are now dropped by `--exclude-tests`: that |
| 72 | +camelCase project name is one dot-less path segment, which the exact dot-component |
| 73 | +guards missed, so `_is_test_path` gained a safe `unittest` substring rule. |
| 74 | + |
| 75 | +### serilog/serilog — 1 finding |
| 76 | + |
| 77 | +| location | verdict | why | |
| 78 | +|---|---|---| |
| 79 | +| `BatchingSink.cs` `_shutdownSignal` (CancellationTokenSource) | **true positive → keep** | `Dispose()` *and* `DisposeAsync()` only call `_shutdownSignal.Cancel()`, never `Dispose()` — a genuine (if benign) undisposed CTS | |
| 80 | + |
| 81 | +Not an async-dispose-tracing miss: the CTS is disposed in **neither** path. This |
| 82 | +is a real catch the oracles' local-not-disposed query can't express, and it stays |
| 83 | +visible. |
| 84 | + |
| 85 | +### JamesNK/Newtonsoft.Json — 2 findings |
| 86 | + |
| 87 | +| location | verdict | why | |
| 88 | +|---|---|---| |
| 89 | +| `TraceJsonReader.cs` `_textWriter` | **FP → baseline** | no-op dispose: a `JsonTextWriter` over an in-memory `StringWriter`/`StringBuilder` holds no unmanaged resource | |
| 90 | +| `JsonSerializer.cs` `serializer.Error` | **FP → baseline** | intra-call self-subscription: the serializer is freshly built from the same `JsonSerializerSettings` whose `.Error` it subscribes; co-lifetimed | |
| 91 | + |
| 92 | +### JoshClose/CsvHelper — 2 findings |
| 93 | + |
| 94 | +| location | verdict | why | |
| 95 | +|---|---|---| |
| 96 | +| `docs-src/.../ConsoleHost.cs` `AppDomain.CurrentDomain.ProcessExit` | **FP → baseline** | process-lived subscriber (a docs-generator host) to a process-lived event source — promoting it to that lifetime is vacuous | |
| 97 | +| `docs-src/.../ConsoleHost.cs` `Console.CancelKeyPress` | **FP → baseline** | same | |
| 98 | + |
| 99 | +## Root-cause categories and the fix that would retire each baseline |
| 100 | + |
| 101 | +The baselined FPs cluster into four analyzer limitations. Each baseline entry is a |
| 102 | +standing request for the corresponding capability — when it lands, retire the |
| 103 | +entry and let the oracle re-confirm clean. |
| 104 | + |
| 105 | +1. **Interprocedural / custom dispose-sink not traced** *(5 NLog timers, |
| 106 | + protobuf `Page.xaml.cs` using-block).* Field-disposal recognition only scans |
| 107 | + top-level `Dispose()` statements for a direct `field.Dispose()`. It misses the |
| 108 | + dispose-pattern override `Dispose(bool disposing)`, `DisposeAsync`, lifecycle |
| 109 | + hooks (`CloseTarget()`/`Close()`), helper-method indirection, disposal of a |
| 110 | + **local alias** of the field, custom dispose-sink methods like |
| 111 | + `WaitForDispose(this Timer)`, and the `using (preExistingLocal)` statement form. |
| 112 | + *Fix:* extend `DisposedOwningFields` (extractor) to additional dispose entry |
| 113 | + points + one level of intra-class call/alias following; longer-term, real |
| 114 | + interprocedural escape/dispose analysis. The cheap, sound first step |
| 115 | + (recognise `Dispose(bool disposing)` + `DisposeAsync` direct field disposal) is |
| 116 | + correct and low-risk but does **not** by itself clear these NLog cases, because |
| 117 | + their disposal is laundered through a local alias **and** a custom-named sink. |
| 118 | + |
| 119 | +2. **No-op `Dispose` not modelled** *(Newtonsoft `TraceJsonReader._textWriter`).* |
| 120 | + We flag any undisposed `IDisposable` structurally, without modelling that the |
| 121 | + concrete `Dispose` releases nothing (`StringWriter`/`StringReader`/`MemoryStream` |
| 122 | + over managed memory). *Fix:* a small "dispose-is-a-no-op" allowlist of BCL |
| 123 | + in-memory types for the field case. (Related, already shipped for one case: |
| 124 | + [`cts-field-dispose-optional.md`](cts-field-dispose-optional.md).) Note the NLog |
| 125 | + `_xmlSource` / `_reusable*Stream` reals are the *same* benign shape but are |
| 126 | + **kept visible** — they're genuinely undisposed; only Newtonsoft's is also |
| 127 | + structurally a no-op AND not worth surfacing. Revisit whether benign-managed |
| 128 | + field leaks should be downgraded as a class. |
| 129 | + |
| 130 | +3. **Lifetime-unaware subscription** *(protobuf `XsltOptions`, Newtonsoft |
| 131 | + `serializer.Error` self-subscriptions; CsvHelper process-lived host).* OWN014's |
| 132 | + premise — a long-lived source outlives a shorter-lived subscriber — fails when |
| 133 | + publisher and subscriber are **co-lifetimed** (same owner, or both freshly |
| 134 | + created in one call) or the subscriber is **itself process-lived**. *Fix:* |
| 135 | + compare subscriber vs. source lifetime (extend the `source: "self"` handling to |
| 136 | + co-created locals and to process-lived hosts) rather than keying on "source is |
| 137 | + static/injected". See [`subscription-leaks-and-profiles.md`](subscription-leaks-and-profiles.md). |
| 138 | + |
| 139 | +4. **Non-product trees** *(protobuf `assorted/`, CsvHelper `docs-src/`, protobuf |
| 140 | + `BuildToolsUnitTests/`).* Sample/extension/doc-generator code that was never |
| 141 | + meant to be production-clean. The generic `unittest` rule now covers camelCase |
| 142 | + test projects; the remaining repo-specific sample trees (`assorted/`, |
| 143 | + `docs-src/`) are handled per-entry in the baseline rather than by polluting the |
| 144 | + generic `_is_test_path` with repo-specific directory names. |
| 145 | + |
| 146 | +## How the baseline stays honest |
| 147 | + |
| 148 | +- **Matched by name, not line** — `(repo, file-basename, OWN code, |
| 149 | + message-substring)`. Re-runs clone the target at HEAD and line numbers drift; |
| 150 | + the field/event/local name in the message does not. |
| 151 | +- **Suppresses only confirmed FPs.** True positives (serilog CTS; NLog benign |
| 152 | + field leaks) are never baselined — they remain the visible proof the niche |
| 153 | + works. |
| 154 | +- **Self-retiring.** Each entry names the fix that obsoletes it. When that lands, |
| 155 | + delete the line; if the FP was real after all, the oracle re-surfaces it. |
| 156 | +- **Verified in CI.** `oracle_compare.py --selftest` covers the baseline |
| 157 | + loader, the name-not-line match key, repo scoping, the `*` wildcard, the |
| 158 | + render, and the `unittest` path rule. |
0 commit comments