#13355
[Feature] Avoid eager full-inventory materialization, duplicate leaf/qualified literal matching, and monolithic JsonArray replies in ReaGhidraBridge
Before submitting
- I searched the open and closed issues and pull requests for a related proposal.
- I understand the contribution scope must be reviewed before integration; open questions are welcome here.
- This request does not include credentials, private samples, or sensitive target data.
Area
Native analysis or decompilation
Current limitation
Source inspection of bridge/ghidra/ReaGhidraBridge.java on origin/main (d0929f9aa2) identifies three remaining scaling bottlenecks in Ghidra search and inventory construction (source-derived; not benchmarked in live Ghidra here):
- Duplicate leaf + qualified literal matching in
spellingMatches(bridge/ghidra/ReaGhidraBridge.java:2753-2756):matcher.matches(qualified) || (!leaf.equals(qualified) && matcher.matches(leaf))runs the matcher twice on every non-matching qualified symbol. While the comment notes a leaf is a suffix of the qualified spelling for literal searches, non-matching literal searches still re-runmatcher.matches(leaf)whenmatcher.matches(qualified)returnedfalse(unless a regex uses start anchors or qualified delimiters). - Unbounded in-memory
JsonArrayconstruction duringsearch(bridge/ghidra/ReaGhidraBridge.java:2696-2724): builds a single fullJsonArray itemsholding every matchingJsonObject(includingfactsandmatched_aliases) in Java heap and serializes one monolithic NDJSON response line, amplifying peak heap in the Ghidra JVM and in Node's NDJSON parser on broad queries. - Eager full-table materialization and sorting in
names(),procedures(), andstrings()(bridge/ghidra/ReaGhidraBridge.java:2758-2880): iterates the entire symbol/function/defined-data tables, constructs sorted immutable lists (symbolFacts, aliases, charset names) up front even for a single selective query or name lookup beforeprocedureNameIndexis populated.
Use cases
Large binaries (e.g., stripped mobile libraries, C++ binaries with deep namespace hierarchies, firmware images) queried via search_procedures, search_strings, list_procedures, or list_strings under bounded Ghidra JVM heap.
Desired outcome and success criteria
- Skip redundant
matcher.matches(leaf)checks when!matcher.matches(qualified)is already decisive (e.g., all unanchored literal searches, and regexes without^/\A/\bboundary sensitivity on the namespace separator). - Bound or stream large inventory/search replies across the Ghidra Unix socket (while preserving exact deterministic sort order,
matched_aliases, and truncation/error semantics). - Avoid eagerly materializing full
names()/procedures()/strings()lists with fullsymbolFactswhen serving targeted operations.
Expected interaction with targets
- Read existing files or captured data
Verification available so far
- Idea only; I need help defining checks
Verification details (optional)
Source-derived analysis at d0929f9aa2. Live JVM heap and wall-clock impact on large Ghidra programs remain unmeasured.
Alternatives considered
- Merged PRs #13305 and #13310 indexed
procedureNameIndex/symbolTable.getSymbols(name)and parallelized language catalog checks, and #13278 / #13292 / #13299 track symbol-table lookup indexing, non-ASCII string search flood mitigation, and workflow scale bounds. None addressspellingMatchesdouble matching on misses, monolithicJsonArraysearch replies, or eagernames()/procedures()/strings()fact materialization.
Possible direction
- Add a
boolean needsLeafCheckflag onValueMatcher(falsefor substring/literal matchers sinceleafis always a substring ofqualified— wait: preserveleaf.equals(qualified)exact edge cases and anchored/separator regexes). - Stream chunked NDJSON or cursor-bounded pages from
ReaGhidraBridge.search(...)/ list commands, and defer alias/symbolFactsobject creation until a row matches or is requested.
References
- Related issues/PRs: #13278, #13292, #13299, merged PRs #13305, #13310
Activity
0No activity yet.