sipeed/picoclaw · critical

error in open panic: %v

Error message

error in open panic: %v

What it means

Windows counterpart of the unix panic-file open failure: initPanicFile could not create/open the panic log (O_WRONLY|O_SYNC|O_APPEND, 0600) and panics at startup, aborting the launcher before logging is initialized.

Source

Thrown at pkg/logger/panic_win.go:17

//go:build windows
// +build windows

package logger

import (
	"fmt"
	"io"
	"os"

	"golang.org/x/sys/windows"
)

func initPanicFile(panicFile string) io.WriteCloser {
	file, err := os.OpenFile(panicFile, os.O_WRONLY|os.O_CREATE|os.O_SYNC|os.O_APPEND, 0o600)
	if err != nil {
		panic(fmt.Sprintf("error in open panic: %v", err))
	}
	err = windows.SetStdHandle(windows.STD_ERROR_HANDLE, windows.Handle(file.Fd()))
	if err != nil {
		panic(fmt.Sprintf("Failed to redirect stderr to file: %v", err))
	}
	os.Stderr = file
	return file
}

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. Read the %v errno in the panic text — share violation vs access denied points to locking vs permissions
  2. Set PICO_HOME to a user-writable location (e.g. under %LOCALAPPDATA%) or grant the user modify rights on the logs directory
  3. Exclude the logs directory from AV scanning and clear stale exclusive locks
  4. Ensure only one launcher instance runs per home directory

Example fix

# before
set PICO_HOME=C:\Program Files\Picoclaw

# after
set PICO_HOME=%LOCALAPPDATA%\Picoclaw
Defensive patterns

Strategy: validation

Validate before calling

if probe, err := os.OpenFile(panicPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600); err != nil {
    return fmt.Errorf("panic log %s not writable: %w", panicPath, err)
} else {
    probe.Close()
}

Try / catch

Startup abort: capture the stderr text in the service wrapper/event log, classify as an environment (permissions/locking) incident, and block rollout until the path is writable.

Prevention

When it happens

Trigger: The home/logs directory is read-only or ACL-restricted on Windows; the panic log is held with an exclusive lock by another process (antivirus scan, a second launcher instance, a log viewer); an invalid path component (reserved name, trailing dot); disk full.

Common situations: Running from Program Files without elevation; AV products briefly locking freshly created log files; a previous crashed instance still holding the handle; roaming-profile path redirection.

Related errors


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/6a74d8cc9a8201a4. Report an issue: GitHub.