PulseAugur
EN
LIVE 09:56:51

Go's slog and log packages deadlock due to shared mutex

A deadlock issue has been identified in Go's slog and log packages when they share a mutex. This occurs if slog.SetDefault is configured with a handler that routes back to the log package, leading to a deadlock on the initial log write. The problem was demonstrated by Smeldr's CaptureLogs() function using the default handler, and a fix involves detecting the type and substituting a direct stderr writer, along with a CI test to catch future regressions. AI

IMPACT Potential for deadlocks in Go applications using logging features.

RANK_REASON Identifies a bug in a programming language's standard library packages.

Read on Mastodon — fosstodon.org →

AI-generated summary · Google Gemini · from 1 sources. How we write summaries →

Go's slog and log packages deadlock due to shared mutex

COVERAGE [1]

  1. Mastodon — fosstodon.org TIER_1 English(EN) · [email protected] ·

    Go's slog and log packages share a mutex. Call slog.SetDefault with a handler that routes back through log and you get a deadlock on the goroutine's first log w

    Go's slog and log packages share a mutex. Call slog.SetDefault with a handler that routes back through log and you get a deadlock on the goroutine's first log write. Smeldr's CaptureLogs() hits this with the built-in default handler. Fix: detect the type, swap in a direct stderr …