From 9440984a832db849d9ec96c937e30a34cdb5e6c7 Mon Sep 17 00:00:00 2001 From: allsmog Date: Wed, 22 Oct 2025 13:32:46 -0700 Subject: [PATCH] Fix Go extractor silent failures and improve error recovery The extractor was calling log.Fatal() when file extraction failed, causing the entire extraction process to terminate silently on the first error. This was particularly problematic for OOM errors which would only appear in build-tracer logs, not in the extractor output. Changes: - Replace log.Fatal() with log.Printf() to log errors without terminating - Add panic recovery in file extraction goroutines to catch OOM errors - Move cleanup (semaphore release, WaitGroup.Done) into defer block to ensure proper cleanup even when panics occur This allows extraction to continue processing remaining files when individual files fail, and ensures errors are visible in extractor logs. --- go/extractor/extractor.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/go/extractor/extractor.go b/go/extractor/extractor.go index 67c127375847..8d0bb7a2b38f 100644 --- a/go/extractor/extractor.go +++ b/go/extractor/extractor.go @@ -692,12 +692,18 @@ func (extraction *Extraction) extractPackage(pkg *packages.Package) { extraction.WaitGroup.Add(1) extraction.GoroutineSem.acquire(1) go func(astFile *ast.File) { + defer func() { + if r := recover(); r != nil { + log.Printf("Panic during file extraction in package %s: %v", pkg.PkgPath, r) + } + extraction.GoroutineSem.release(1) + extraction.WaitGroup.Done() + }() + err := extraction.extractFile(astFile, pkg) if err != nil { - log.Fatal(err) + log.Printf("Error extracting file in package %s: %v", pkg.PkgPath, err) } - extraction.GoroutineSem.release(1) - extraction.WaitGroup.Done() }(astFile) } }