Bug: fatal error: concurrent map writes #76
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/OpenSpec
Kind/Security
Kind/Testing
Priority/Critical
Priority/High
Priority/Low
Priority/Medium
RFC - Request For Comments
Reviewed/Confirmed
Reviewed/Duplicate
Reviewed/Invalid
Reviewed/Won't Fix
Status/Abandoned
Status/Blocked
Status/Need More Info
hermes-attempted
hermes-needs-clarification
hermes-ready
hermes-review
hermes-wip
human-required
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
agentic-forges/forgejo-mcp#76
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When running commands, the forgejo-mcp binary panics with 'fatal error: concurrent map writes'. This indicates a race condition in the code, likely from multiple goroutines writing to the same map without a mutex. This makes the CLI tool unsafe for concurrent or repeated use. See stack trace:\n\n
\nfatal error: concurrent map writes\n\ngoroutine 20 [running]:\nruntime.throw({0x55bca0?, 0x1?})\n\t/home/linuxbrew/.linuxbrew/Cellar/go/1.26.0/libexec/src/runtime/panic.go:1024 +0x5d\nruntime.mapassign_fast64(...)\n\t/home/linuxbrew/.linuxbrew/Cellar/go/1.26.0/libexec/src/runtime/map_fast64.go:217 +0x305\ncodeberg.org/goern/forgejo-mcp/v2/cmd.init.0()\n\t/home/ubuntu/.openclaw/workspace/forgejo-mcp/cmd/cmd.go:116 +0x79\n...\n\nInvestigation & Reproducer
Created a reproducer test suite in
test/race/race_test.go. PR incoming.Test Suite
Run with:
go test -race -count=10 -timeout 120s ./test/race/Tests included:
Findings
Could not reproduce the exact
mapassign_fast64crash with current code under-race. mcp-go v0.43.2 properly synchronizes its internal tool maps withsync.RWMutex.Secondary bug:
cmd.init()callsflag.Parse()on globalflag.CommandLineduring package initialization, makinggo test ./cmd/impossible (test framework flags conflict). Should move flag parsing toExecute().Secondary bug: nil pointer dereference in tool handlers. Many handlers access
resp.StatusCodeBEFORE checkingerr != nil. When API returns(nil, nil, err), this panics:This nil-pointer crash under concurrent load may be the actual trigger for the reported panic.
Possible Root Cause
The
mapassign_fast64indicates a map with int64 keys — none exist in project code. Most likely candidate: a nil-pointer panic in a handler (finding #3) cascading into undefined behavior under the mcp-go worker pool concurrent execution.