Skip to content

Commit c029e8d

Browse files
authored
Merge pull request #226 from PhysShell/claude/oracle-sweep-201
docs: oracle sweep over 5 new OSS repos, 8 precision-gap follow-ups (issue #201)
2 parents ba59ccf + 232a697 commit c029e8d

8 files changed

Lines changed: 602 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Fix: Dispose() also disposes menuForm (a Form is IDisposable; disposing it
2+
// tears down its whole child-control tree, per WinForms' own Control.Dispose
3+
// semantics — see field-notes-patterns.md for that transitive-disposal idiom).
4+
using System;
5+
using System.Windows.Forms;
6+
7+
internal sealed class ShapeManager : IDisposable
8+
{
9+
private Form menuForm;
10+
private readonly HistoryStack history = new HistoryStack();
11+
12+
internal void CreateToolbar()
13+
{
14+
menuForm = new Form { ShowInTaskbar = false };
15+
menuForm.Show();
16+
}
17+
18+
public void Dispose()
19+
{
20+
history.Dispose();
21+
menuForm?.Dispose();
22+
}
23+
}
24+
25+
internal sealed class HistoryStack : IDisposable
26+
{
27+
public void Dispose() { }
28+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Reduced from ShareX/ShareX @ 0df9ca4, ShareX.ScreenCaptureLib/Shapes/ShapeManagerMenu.cs
2+
// (CreateToolbar, ~lines 62-1246) and ShapeManager.cs:2406-2411 (Dispose) — found by
3+
// the issue #201 oracle sweep.
4+
//
5+
// ShapeManager builds its on-screen annotation toolbar as a plain WPF-Forms `Form`
6+
// (`menuForm`) hosting a `ToolStripEx` with ~38 buttons/menu items/numeric-updowns/
7+
// combo-boxes, all created and owned by this class. `ShapeManager.Dispose()` exists
8+
// and disposes some of what the class owns (`history`), but forgets `menuForm`
9+
// entirely — every capture/annotation session leaks a full `Form` plus its whole
10+
// toolbar tree, because nothing else ever closes or disposes it either.
11+
using System;
12+
using System.Windows.Forms;
13+
14+
internal sealed class ShapeManager : IDisposable
15+
{
16+
private Form menuForm;
17+
private readonly HistoryStack history = new HistoryStack();
18+
19+
internal void CreateToolbar()
20+
{
21+
menuForm = new Form { ShowInTaskbar = false };
22+
// ...builds tsMain and ~38 ToolStrip child items, all added to menuForm...
23+
menuForm.Show();
24+
}
25+
26+
public void Dispose()
27+
{
28+
// real code also calls DeleteAllShapes(); irrelevant to the leak.
29+
history.Dispose();
30+
// menuForm is never disposed or closed anywhere in this class.
31+
}
32+
}
33+
34+
internal sealed class HistoryStack : IDisposable
35+
{
36+
public void Dispose() { }
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// OwnLang model of the ShareX ShapeManager.menuForm leak (issue #201 oracle
2+
// sweep): a class's Dispose() disposes some of its owned resources (`history`)
3+
// but forgets one it itself created (`menuForm`) — a plain owned-field leak,
4+
// the generic OWN001 acquire-with-no-release. See notes.md for the real finding.
5+
module Corpus
6+
resource Form {
7+
acquire create
8+
release dispose
9+
kind "disposable"
10+
}
11+
resource HistoryStack {
12+
acquire create
13+
release dispose
14+
kind "disposable"
15+
}
16+
fn Dispose(unused: int) {
17+
let menuForm = acquire Form(unused); // CreateToolbar(): menuForm = new Form { ... }
18+
let history = acquire HistoryStack(unused);
19+
release history; // Dispose(): history.Dispose()
20+
// no `release menuForm;` — Dispose() never touches menuForm (OWN001)
21+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OWN001
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# ShareX — the annotation toolbar `Form` is built but never disposed
2+
3+
**Found by the issue #201 oracle sweep** (`docs/notes/oracle-sweep-2026-07-10.md`).
4+
Target: `ShareX/ShareX` @ `0df9ca4`, `ShareX.ScreenCaptureLib/Shapes/ShapeManagerMenu.cs`
5+
(`CreateToolbar`, ~lines 62-1246) and `ShapeManager.cs:2406-2411` (`Dispose`).
6+
7+
**Pattern.** `ShapeManager.CreateToolbar()` builds the on-screen annotation/region-
8+
capture toolbar as a plain `Form` (`menuForm`), hosting a `ToolStripEx` with roughly
9+
38 buttons, menu items, numeric-updowns, and combo-boxes — all created and owned
10+
by `ShapeManager` itself (verified: every one of those ~38 fields is populated in
11+
`CreateToolbar`, and `menuForm.Controls.Add(tsMain)` / `tsMain.Items.Add(...)` wires
12+
them into the same `Form`). `ShapeManager` **does** implement `IDisposable` and
13+
**does** have a real `Dispose()`:
14+
15+
```csharp
16+
public void Dispose()
17+
{
18+
DeleteAllShapes();
19+
history.Dispose();
20+
}
21+
```
22+
23+
— but it never disposes, closes, or otherwise releases `menuForm`. Grepping the
24+
whole `ShapeManager` partial class (`ShapeManager.cs` + `ShapeManagerMenu.cs`) turns
25+
up no `menuForm.Dispose()`/`.Close()` call anywhere. Every capture/annotation
26+
session that shows the toolbar leaks a full `Form` and its entire control tree —
27+
a real, non-trivial resource leak (not merely theoretical: `CreateToolbar` is called
28+
fresh each time the toolbar is (re)shown).
29+
30+
**What the checker says (real oracle-sweep extractor output, `--flow-locals`,
31+
`--severity warning`):**
32+
33+
```text
34+
ShapeManagerMenu.cs:47: [OWN001] IDisposable field 'menuForm' (type 'Form') is
35+
never disposed — its owner 'ShapeManager' leaks it (leak) [resource: disposable field]
36+
```
37+
38+
(plus one OWN001 per never-disposed ToolStrip child field — all transitively real,
39+
since `menuForm` itself is the actual leak root; see the sweep note for the full
40+
count.) Own.NET catches this correctly — cross-checked against the real source, no
41+
`Dispose()`/`Close()` call exists anywhere for `menuForm` in either partial-class
42+
file.
43+
44+
**This `case.own`** models the shape generically: a class's `Dispose()` releases
45+
one owned resource (`history`, standing in for the real `HistoryStack`/`history`
46+
field) but never touches a second one it also owns (`menuForm`) — the plain
47+
owned-field-never-released OWN001, same core logic as the rest of the field-dispose
48+
corpus. As with the rest of the corpus, `case.own` is a hand reduction of the C#
49+
pattern (one representative field standing in for the ~38 that all share the same
50+
root cause), not a line-for-line transcription of `ShapeManagerMenu.cs`.
51+
52+
**Draft verdict: true positive**, per the issue #201 sweep's triage guardrails
53+
(final TP/FP confirmation is the maintainer's call; this is not itself a bug report
54+
filed against ShareX upstream — see `docs/notes/mining.md`'s "reporting upstream is
55+
a separate, manual step").

0 commit comments

Comments
 (0)