Repository navigation
Conversation
… description Lets agents see why an analyzer is on or off before re-enabling one an extension disabled deliberately. Claude-Session: https://claude.ai/code/session_01FNRMtY3ocPVd7kxcUGi2X6
…n an unanalysed program Ghidra stores only analysis option values that were set; the analyzers, their defaults and descriptions are registered when an AutoAnalysisManager is created for the program. On a program nothing had analysed, list_analyzers returned an empty list and configure_analyzer answered 'Analyzer not found', and descriptions were missing wherever no manager existed yet. Both now create the manager first. AnalyzerDescriptionsGhidraTest runs against a real program (fails without the fix); the two Mockito tests from 766b2510 are dropped, since the manager cannot be built over a mocked Program. Claude-Session: https://claude.ai/code/session_01FNRMtY3ocPVd7kxcUGi2X6
ProgramSaves.awaitAnalysis, the sweep's wait, the dirty queue's check and list_project_files' analyzing flag called AutoAnalysisManager .getAnalysisManager only to ask whether analysis was running. That call creates a manager when none exists, and a manager instantiates every analyzer (the x86 function-start pattern searchers alone are several MB), so saving a program or building a tree attached full auto-analysis to a program nothing had asked to analyse. With no manager nothing is analysing; they now check hasAutoAnalysisManager first. Claude-Session: https://claude.ai/code/session_01FNRMtY3ocPVd7kxcUGi2X6
AnalyzerDescriptionsGhidraTest runs ClassSearcher.search, after which every AutoAnalysisManager in the JVM instantiates all analyzers, and the real-Ghidra tier leaves dozens of programs open. The offline + core run died with OutOfMemoryError on Gradle's default worker heap; Maven's default (a quarter of RAM) was enough. Claude-Session: https://claude.ai/code/session_01FNRMtY3ocPVd7kxcUGi2X6
|
I'd like to take this ahead of #636. Its four commits don't depend on the settings registry: the first two apply to dev cleanly, and the third conflicts only in ProgramSaves.java, against the bounded analysis wait that landed in a2b705c. Could you retarget it onto dev? #636 needs a longer review and I'd rather not hold this fix behind it. The bug is real on dev today: ProgramSaves, DirtyQueue and SweepJob all call getAnalysisManager just to ask whether analysis is running. |
rahul05ranjan
left a comment
There was a problem hiding this comment.
I checked the central claim against upstream Ghidra and it holds: AutoAnalysisManager's private constructor (AutoAnalysisManager.java:149) runs initializeAnalyzers() → registerOptions(), so analyzer names/defaults/descriptions only appear in Program.ANALYSIS_PROPERTIES once a manager exists for the program. hasAutoAnalysisManager (line 944) is the right pre-check, and every site you converted (awaitAnalysis, analysisStatus, DirtyQueue.isAnalyzing, SweepJob.waitForAnalysisIfNeeded) only ever needed the side-effect-free query — creating a manager just to ask "is anything running?" was the actual bug. The analysisOptions() helper doing the deliberate getAnalysisManager for list_analyzers/configure_analyzer is the correct split.
One thing worth being aware of: because the manager registers a close-listener and holds every analyzer instance, a single list_analyzers call now pins several MB of analyzers to that program for its remaining lifetime — the same cost the maxHeapSize = '2g' bump in build.gradle is paying for in the test JVM. On the headless server with one program that's a non-issue, but on the GUI server an agent walking over dozens of open programs with list_analyzers would now leave a full analyzer set resident in each. If that ever matters, a variant that registers options without building the scheduler lists (e.g. a lighter ClassSearcher-based enumeration) could avoid it — no action needed unless you've seen the GUI footprint.
Small nit on the test: AnalyzerDescriptionsGhidraTest.listAnalyzersDescribesStockAnalyzersOnAnUnanalysedProgram asserts a description only for "Shared Return Calls". An assertion that at least a handful of entries carry a non-blank description (or that entries.size() is well above the handful of stale boolean options that pass the getBoolean filter) would catch a regression where analysisOptions() stops registering and the list quietly shrinks to a couple of pre-stored names.
Stacked on #636, which is stacked on #635. This PR's own changes are the four commits below.
list_analyzersandconfigure_analyzernow report each analyzer's description, so an agent can see why an extension turned an analyzer off before turning it back on.AutoAnalysisManagerfor the program.list_analyzersreturned an empty list andconfigure_analyzeranswered "Analyzer not found".AnalyzerDescriptionsGhidraTestruns against a real program and fails without this fix.list_project_files' analyzing flag all calledAutoAnalysisManager.getAnalysisManagerjust to ask whether analysis was running.hasAutoAnalysisManagerfirst.ClassSearcher.search, every analysis manager in the JVM instantiates all analyzers, and the offline plus real-Ghidra run ran out of memory on Gradle's default worker heap. Maven's default heap was already enough.Tests
https://claude.ai/code/session_01FNRMtY3ocPVd7kxcUGi2X6