Files
magpie/go.mod
T
yetone 861bbef2d5 sqlite: an environment entry with no "=" no longer ends magpie at its first SQLite open, where modernc's libc printed TODOTODO and exited (#2327, goodloop)
A magpie started from Alfred under the MacSec DLP tool quit about two
seconds after launch, exit 1, no crash report. Its environment held an
entry with no "=" ("hains/MacSec/libesafenet.dylib", a fragment of the
tool's injected dylib path). The first SQLite open (a session scan)
reads SQLITE_TMPDIR through modernc's libc, whose getenv on darwin,
windows and the BSDs (libc.go, not the musl build Linux uses) hits that
entry, calls todo() and os.Exit(1): "libc.go:1816:getenv: TODOTODO
"SQLITE_TMPDIR" "hains/MacSec/libesafenet.dylib"", the reporter's line.

New package internal/sqlitedb is the one importer of modernc.org/sqlite
in magpie's own code (it replaces the blank imports in
internal/provider/importapps.go and internal/agent/cindy.go, the only
two). Its init hands libc.SetEnviron a copy of os.Environ with the
entries that have no "=" left out, before any open and before any
goroutine, which also keeps libc's unlocked first-use SetEnviron from
racing. modernc.org/libc becomes a direct requirement (v1.67.6, same
version). Snapshot timing: libc's copy is now taken at init, not at the
first open; nothing in magpie sets SQLITE_TMPDIR, TMPDIR or TZ, the
only variables SQLite reads.

Run (worktree at origin/main 01c41e8ba, sandbox HOME, go1.26.8 darwin):
- internal/sqlitedb: TestSQLiteSurvivesMalformedEnv starts the test
  binary again with the reporter's entry first in a raw Env and opens
  and reads a database there; TestWellFormed; and
  TestOnlyThisPackageReachesSQLite (no non-test file outside
  internal/sqlitedb imports modernc.org/sqlite or modernc.org/libc).
- Broken by hand: with init's SetEnviron call removed,
  TestSQLiteSurvivesMalformedEnv goes red with the child's exit 1 and
  the reporter's exact TODOTODO line. With cindy.go importing
  modernc.org/sqlite again, the import guard goes red naming it.
- go test -p 1 -count=1 -tags nogui ./internal/sqlitedb ./internal/agent
  ./internal/provider ./internal/sessions ./internal/proc: all ok.
- gofmt -l: clean. go vet -tags nogui on the three packages for
  GOOS=darwin, linux, windows: clean. go mod verify: ok.
- Real binary: go build -tags nogui, then execve'd (python ctypes, raw
  envp) as `magpie sessions` with the reporter's entry and a sandbox
  HOME holding an opencode.db: exit 0, it listed. The hand-broken
  binary for comparison couldn't be linked (disk full), so that run
  shows only that the fixed binary survives, not that this command
  reached SQLite; the test above is what goes red on the old code.
- Not tried: the reporter's Alfred + MacSec machine, Windows.
- Linux getenv (musl-based) already skips such entries; the test passes
  there either way.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00

60 lines
2.4 KiB
AMPL

module github.com/yetone/magpie
go 1.26.8
require (
github.com/Calcium-Ion/moejs v0.1.0-alpha.4
github.com/charmbracelet/bubbles v0.21.1
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
github.com/go-ole/go-ole v1.3.0
github.com/godbus/dbus/v5 v5.2.2
github.com/klauspost/compress v1.18.3
github.com/pelletier/go-toml/v2 v2.2.4
github.com/tidwall/gjson v1.19.0
github.com/tidwall/jsonc v0.3.3
github.com/wailsapp/wails/v3 v3.0.0-beta.24
golang.org/x/net v0.56.0
golang.org/x/sys v0.46.0
golang.org/x/term v0.44.0
golang.org/x/text v0.39.0
gopkg.in/yaml.v3 v3.0.1
modernc.org/libc v1.67.6
modernc.org/sqlite v1.44.3
)
require (
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 // indirect
github.com/adrg/xdg v0.5.3 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.4.1 // indirect
github.com/charmbracelet/x/ansi v0.11.5 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.9.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
github.com/coder/websocket v1.8.14 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
)