Files
OwnCord/Server/plugin/host_commands_race_test.go
T
J3vb db0275a290 fix: batch of 29 correctness fixes across server and client (#1369)
* fix(ws): 2 defect(s) (OC-0013, OC-0140)

* fix(voice): 1 defect(s) (OC-0044)

* fix(ws): 1 defect(s) (OC-0024)

* fix(server): 1 defect(s) (OC-0027)

* fix(ws): 1 defect(s) (OC-0028)

* fix(server): 7 defect(s) (OC-0033, OC-0066, OC-0067, OC-0068, OC-0074, OC-0077, OC-0106)

* fix(ws): 1 defect(s) (OC-0051)

* fix(client): 1 defect(s) (OC-0053)

* fix(client): 1 defect(s) (OC-0055)

* fix(service): 1 defect(s) (OC-0069)

* fix(voice): 1 defect(s) (OC-0072)

* fix(service): 1 defect(s) (OC-0082)

* fix(client): 1 defect(s) (OC-0083)

* fix(plugin): 1 defect(s) (OC-0088)

* fix(plugin): 4 defect(s) (OC-0104, OC-0126, OC-0127, OC-0133)

* fix(admin): 1 defect(s) (OC-0110)

* fix(client): 1 defect(s) (OC-0114)

* fix(api): 1 defect(s) (OC-0139)

* fix(client): 1 defect(s) (OC-0149)

* test(server): adapt existing tests to updated OpenDM and IncrementMentionCounts signatures

* style(plugin): modernize loops and goroutine spawns in race test

* fix(ws): mirror the focus admission gate in the post-subscribe revalidation

* fix(service): detach DM post-commit side effects from the request ctx, fail delete closed, add empty-fan-out fallback

* fix(plugin): preserve enabled intent when upgrade reactivation hits a runtime-less build

* chore(skills): harden bughunt-fix workflow and fold review lessons into bughunt-run/db-change

* Add comprehensive documentation for task-observer skill

- Introduced environments.md to outline activation setup, compaction behavior, and handoff-doc mode.
- Created skill-authoring.md detailing taxonomy, licensing, confidentiality, and editing rules for skill creation.
- Added weekly-review.md for a structured review process of OPEN observations, including scheduled and in-session fallback modes.

* chore(go): pin toolchain go1.26.6 (stdlib CVE fixes flagged by govulncheck)
2026-08-14 10:05:40 +02:00

55 lines
1.8 KiB
Go

// OC-0088: DispatchCommand read r.runtimePlatform without the registry lock
// that Close() writes it under, unlike the sibling reader activate() which
// takes r.mu.RLock() first specifically to avoid observing a concurrent
// Close mid-use. This file pins the fix with a concurrent -race test that
// runs under every build variant (no wazero dependency: the default build's
// runtimePlatform is always nil, but Close() still writes it under lock,
// which is enough for the race detector to flag the unguarded read).
package plugin
import (
"context"
"sync"
"testing"
)
func TestDispatchCommandRuntimePlatformRace(t *testing.T) {
mem := openPluginTestDB(t)
reg, err := NewRegistry(Config{Directory: t.TempDir(), Store: mem})
if err != nil {
t.Fatalf("NewRegistry: %v", err)
}
ctx := context.Background()
manifest, err := ParseManifest([]byte(`{"name":"racer","version":"0.1.0","entrypoint":"p.wasm","permissions":["commands"],"commands":[{"name":"roll"}]}`))
if err != nil {
t.Fatalf("ParseManifest: %v", err)
}
if err := reg.installFromDisk(ctx, foundPlugin{Manifest: manifest, WASMPath: "p.wasm"}); err != nil {
t.Fatalf("installFromDisk: %v", err)
}
reg.mu.RLock()
inst := reg.byName["racer"]
reg.mu.RUnlock()
if err := reg.RegisterCommand("roll", inst); err != nil {
t.Fatalf("RegisterCommand: %v", err)
}
// Race DispatchCommand's unsynchronised read of r.runtimePlatform (line
// 71 in host_commands.go) against Close's r.mu.Lock()-guarded write of
// the same field. Before the fix, `go test -race` reports:
// DATA RACE ... Registry.Close() ... Registry.DispatchCommand()
var wg sync.WaitGroup
for range 8 {
wg.Go(func() {
for range 500 {
reg.DispatchCommand(ctx, 1, 2, "roll", nil)
}
})
}
wg.Go(func() {
_ = reg.Close(ctx)
})
wg.Wait()
}