Skip to content

remove: two memory-monitoring packages nothing imported, one of them a listener - #365

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/remove-profiling-memmon-245
Aug 5, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/remove-profiling-memmon-245

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #245.

pkg/profiling started an HTTP server on a bare :port — which binds every
interface, not loopback — and served the five standard net/http/pprof
handlers plus four of its own, two of which (/memory/gc, /memory/free)
mutate process state. No authentication, no bind restriction. That is the
security issue in #245.

pkg/memmon is the same idea with the listener left out: 1,464 lines of
sampling, alerting and profile-writing that reach nothing.

Neither package has an importer. go build ./... and go vet ./...
produce identical output before and after the deletion, which is the whole
argument for deleting rather than documenting or hardening: there is no
caller to migrate and no behaviour to preserve. global.profile_port was
already removed rather than wired; the config doc comment now says that
restoring the setting means building the server too, with an authenticated
non-wildcard bind.

What goes

file lines
pkg/profiling/memory.go 592
pkg/profiling/memory_test.go 682
pkg/memmon/monitor.go 595
pkg/memmon/profiler.go 321
pkg/memmon/monitor_test.go 548
docs/memory-monitoring.md —

Plus the mkdocs.yml nav entry, the two .coverage-floors lines, and
docs/concurrency-patterns.md's go test -race ./pkg/memmon/... example,
which now names ./internal/vfs/... — a package that exists and is worth
running the race detector against.

SECURITY.md said no pprof listener is started at any address. That was
true of the shipped binary and misleading about the repository, since the
code to start one was sitting in pkg/profiling. It now says there is no
longer any code here that could start one, and points at
go test -cpuprofile for the legitimate need.

The coverage-floor comment is the interesting part

The floors file carried ten lines explaining that pkg/memmon's floor
flaked between 51.0% and 50.6% depending on garbage-collector timing. Both
lines are gone with the package, but the lesson is not, so it moved into the
file header: chasing that flake is what found the larger defect. The varying
statement was an alert branch whose test accepted either outcome —
t.Log("No alerts generated (may be normal...)") — so deleting the branch
entirely left the test green. A gate with zero margin is what made that
visible. Widen the test, not the margin.

Verification

  • go build ./..., go vet ./... — output unchanged by the deletion
  • full -short -race suite green
  • coverage gate reports 33 packages at or above their floor
  • mutated to confirm the gate holds: re-adding pkg/memmon 51 to
    .coverage-floors fails with "a floor of 51% is set but the coverage
    profile has no data for it"
    . A half-landed deletion — floors kept,
    package gone — cannot pass CI.

…a listener

pkg/profiling built a mux with the five standard net/http/pprof handlers plus
/memory/stats, /memory/samples, /memory/gc and /memory/free, and served it from
`Addr: fmt.Sprintf(":%d", port)` — every interface, two mutating handlers, no
authentication anywhere in the package. pkg/memmon is the same idea with the
listener left off: MemoryMonitor, Profiler, leak detection, per-object tracking,
1,464 lines, no importer, and a doc page describing it as a shipped feature with
a Quick Start.

Neither had a Go importer outside its own package. `go build ./...` and
`go vet ./...` are unchanged by removing both, which is the argument: a package
the compiler does not need is a package the documentation should not promise.
Two packages implementing one absent feature is how a reader ends up believing
the feature exists.

v0.11.0 removed `global.enable_pprof` and `global.profile_port` rather than
wiring them, and recorded the reason as "tracked as #245, where the profiling
package's fate is decided with it". This is that decision. Restoring either
setting now means building the server it names, with an authenticated bind that
is not a wildcard — SECURITY.md and the GlobalConfig doc both say so.

Also removed: docs/memory-monitoring.md, its mkdocs.yml nav entry, the
concurrency-patterns.md link and test command, and both .coverage-floors
entries. The gate is what forces the last of those and it was verified by
mutation: leaving `pkg/memmon 51` in place fails with "a floor of 51% is set but
the coverage profile has no data for it", so a deletion cannot half-land.

The floors file's note about pkg/memmon's 51.0%-or-50.6% GC-timing flake was
rewritten into the header as the general lesson rather than deleted with the
entry. The flake was the smaller half of that finding — the test it exposed
accepted either outcome with t.Log("No alerts generated (may be normal...)"), so
deleting the branch under test left it green — and that holds regardless of
which package it happened in.

Closes #245
@scttfrdmn
scttfrdmn merged commit 3040683 into main Aug 5, 2026
33 checks passed
@scttfrdmn
scttfrdmn deleted the fix/remove-profiling-memmon-245 branch September 20, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg/profiling has no importer and serves unauthenticated mutating endpoints: delete it, or make it safe to enable

1 participant