{"record":{"id":"6a74d8cc9a8201a4","repo":"sipeed/picoclaw","slug":"error-in-open-panic-v-6a74d8","errorCode":null,"errorMessage":"error in open panic: %v","messagePattern":"error in open panic: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/logger/panic_win.go","lineNumber":17,"sourceCode":"//go:build windows\n// +build windows\n\npackage logger\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\n\t\"golang.org/x/sys/windows\"\n)\n\nfunc initPanicFile(panicFile string) io.WriteCloser {\n\tfile, err := os.OpenFile(panicFile, os.O_WRONLY|os.O_CREATE|os.O_SYNC|os.O_APPEND, 0o600)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error in open panic: %v\", err))\n\t}\n\terr = windows.SetStdHandle(windows.STD_ERROR_HANDLE, windows.Handle(file.Fd()))\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Failed to redirect stderr to file: %v\", err))\n\t}\n\tos.Stderr = file\n\treturn file\n}\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/logger/panic_win.go#L1-L26","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the %v errno in the panic text — share violation vs access denied points to locking vs permissions","Set PICO_HOME to a user-writable location (e.g. under %LOCALAPPDATA%) or grant the user modify rights on the logs directory","Exclude the logs directory from AV scanning and clear stale exclusive locks","Ensure only one launcher instance runs per home directory"],"exampleFix":"# before\nset PICO_HOME=C:\\Program Files\\Picoclaw\n\n# after\nset PICO_HOME=%LOCALAPPDATA%\\Picoclaw","handlingStrategy":"validation","validationCode":"if probe, err := os.OpenFile(panicPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600); err != nil {\n    return fmt.Errorf(\"panic log %s not writable: %w\", panicPath, err)\n} else {\n    probe.Close()\n}","typeGuard":null,"tryCatchPattern":"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.","preventionTips":["Install per-user under %LOCALAPPDATA%, not Program Files","Enforce single-instance per home to avoid exclusive-lock contention","Add AV exclusions for log directories"],"tags":["logger","panic","windows","filesystem","startup","file-locking"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}