meshery/meshery

[Performance] Prevent double-unlock panic in startNighthawkServer

Open

#18,978 opened on Apr 29, 2026

 (2 comments) (0 reactions) (1 assignee)HTML (3,101 forks)batch import
help wanted

Repository metrics

Stars
 (10,013 stars)
PR merge metrics
 (Avg merge 22d 16h) (332 merged PRs in 30d)

Description

Current Behavior

startNighthawkServer locks nighthawkStatus with a deferred unlock, but it also manually unlocks the same mutex on two error paths.

That creates a double-unlock risk that can panic the server while handling a failed Nighthawk startup.

Expected Behavior

The function should unlock the mutex exactly once on every path.

Screenshots/Logs

Relevant code path:

  • server/helpers/load_test_interface.go
  • defer nighthawkStatus.Unlock() near the top of startNighthawkServer
  • extra nighthawkStatus.Unlock() calls before returning errors

Environment

  • Host OS: Linux
  • Platform: Kubernetes
  • Meshery Server Version: current master
  • Meshery Client Version: current master

To Reproduce

  1. Trigger the Nighthawk startup path.
  2. Make cmd.Start() fail, or make os.Stat(transformCommand) fail.
  3. Observe the function hit a manual unlock and then hit the deferred unlock on return.

Contributor Guides and Handbook

Contributor guide