# command: go test -count=1 -v -run TestF04CryptoSlotReleasedOnPanic ./singlink # working directory: repository root at 23bf613409fd836f2da7b2ba75827dc15d63c918 # toolchain: go version go1.27.4 darwin/arm64 # host: Darwin 27.2.0 arm64; macOS 27.2.1 # started: 2026-11-19T03:53:02Z # ---- combined stdout and stderr ---- === RUN TestF04CryptoSlotReleasedOnPanic crypto_slot_test.go:50: handshake 22 never reached the cryptography section (22 of 22 slots in use) --- FAIL: TestF04CryptoSlotReleasedOnPanic (11.03s) FAIL FAIL github.com/SingLinkLabs/singlink-protocol/singlink 11.496s FAIL # ---- end of output ---- # exit status: 1 # finished: 2026-11-19T03:53:18Z # ---- mutation applied to singlink/server.go for this control run (git diff) ---- diff --git a/singlink/server.go b/singlink/server.go index 074f3f4..c1c091e 100644 --- a/singlink/server.go +++ b/singlink/server.go @@ -273,21 +273,24 @@ func (s *Server) Serve(ln net.Listener) error { // handle) cannot leak it and eventually block every later handshake. func (s *Server) authenticate(flight []byte) (*serverHandshake, *Token, error) { s.guard.crypto <- struct{}{} - defer func() { <-s.guard.crypto }() if s.cfg.cryptoHook != nil { s.cfg.cryptoHook() } hs, err := parseFirstFlight(flight, s.keys) if err != nil { + <-s.guard.crypto return nil, nil, err } tok, err := s.cfg.Issuers.Verify(hs.req.token) if err != nil { + <-s.guard.crypto return nil, nil, err } if !hs.verifyPoP(tok.DevicePub) { + <-s.guard.crypto return nil, nil, errProbe } + <-s.guard.crypto return hs, tok, nil }