fix: analyze durably during one-shot import (functions lost after import) - #21
Open
maci0 wants to merge 1 commit into
Open
fix: analyze durably during one-shot import (functions lost after import)#21maci0 wants to merge 1 commit into
maci0 wants to merge 1 commit into
Conversation
…ort) The project bootstrap (analyzeHeadless -import) passed -noanalysis and relied on the bridge's best-effort program.save() after a TCP analyze. That save silently swallows failures, so a fresh session saw the imported program as un-analyzed (analyzed:false, function_count:0) even though import reported 'Analysis complete', and function list/decompile returned nothing. Analyze inside the one-shot import instead: analyzeHeadless persists the analyzed program on exit, so query sessions see the functions. Verified with analyzeHeadless: import (without -noanalysis) persists FUNCTION_COUNT=2 for mini_pe.exe across separate sessions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After
ghidra-cli import, a fresh session sees the imported program as un-analyzed:program listreports"analyzed":false, function_count:0andfunction list/decompilereturn nothing — even though import printed "Analyzing… Analysis complete!" withfunction_count: 121.Root cause
The project bootstrap (
src/ghidra/bridge.rs::import_oneshot) launchesanalyzeHeadless -import <binary> **-noanalysis** -overwrite. Analysis is deliberately skipped at launch and driven later over TCP (handleAnalyze), whosecurrentProgram.save("Analysis complete", mon)is wrapped in a catch-all:When that save fails (the bridge opens the program in
-processmode where in-place save is not durable), the exception is swallowed — the analyzed program never reaches the project DB, and every later session opens the un-analyzed program.Fix
Remove
-noanalysisfromimport_oneshot.analyzeHeadless -importanalyzes and persists the analyzed program to the project on exit, so query sessions open an already-analyzed program and see the functions. This eliminates the fragile TCP-analyze + best-effort-save path for the common bootstrap case (the bridge still launches with-process -noanalysisso it never re-analyzes).Verification
analyzeHeadless -import(no-noanalysis) onmini_pe.exe, then a separate-process mini_pe.exe -noanalysissession with a count script reportsFUNCTION_COUNT=2— the analysis persisted across sessions.cargo build --releasepasses.