From 6e4dc04fa27bc275b89ee38bdd094d4370622851 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 314fb8a56c13..da3df036be7e 100644 --- a/go/extractor/extractor.go +++ b/go/extractor/extractor.go @@ -706,12 +706,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) } }