Repository navigation
fix(ghidra): pre-create the launch-support config directory - #2470
Conversation
Ghidra's launch support resolves its JDK before the headless run starts and
persists that choice under `<config>/ghidra/<release directory>`. Inside REA's
private runtime a child JVM cannot create those directories, so the first
Windows Ghidra query aborted at ghidra.launch.AppConfig.saveJavaHome with:
java.io.IOException: Failed to create directory:
...\config\ghidra\ghidra_12.1.4_PUBLIC
at ghidra.launch.AppConfig.saveJavaHome(AppConfig.java:145)
at LaunchSupport.findJavaHome(LaunchSupport.java:210)
LaunchSupport then fell back to its interactive prompt, read EOF, and reported
"JDK 21+ (64-bit) could not be found and must be manually chosen!", so the
provider failed with "Ghidra exited before bridge startup" even though
`rea doctor` reported a valid Ghidra installation and JDK.
Create the release directory while this process still owns the runtime, leaving
Ghidra only a file write inside it. The release coordinate comes from the
installation's Ghidra/application.properties (application.version plus
application.release.name) with the extraction directory name as a fallback. On
Windows each level goes through the native private-runtime owner, which opens
every existing component and creates only the final one.
Verified on Windows x64 with Ghidra 12.1.4, a 64-bit Temurin JDK 21, and REA's
packaged native addon: `rea inspect <x64 PE DLL> --provider ghidra` and the
equivalent MCP `binary_overview` call both complete and report 21 segments,
1436 procedures, and 2761 strings. Windows Ghidra remains read-only P0; this
change does not extend that boundary.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
TL;DR: This is a Linux check, and it does not reproduce the Windows bug. On Linux, the head gives the same Ghidra results as its parent, and its new folder has the right name. REA's Linux launch never writes into that folder. ResultsI ran
Not run
Thanks, AbdulAzizWang, for the fix and the detailed write-up. Test setup
CommandsA small node script watched the temporary runtime every 50 ms. All six runs exited 0. 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
@greptileai review |
|
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. Handled in 79f93f3. Added Windows production-boundary launcher scenarios for a renamed installation with readable application.properties, an unreadable/missing properties fallback, and a missing release-key fallback. Each goes through the owned Windows runtime before an injected spawn boundary and asserts the release directory exists. Reaching spawn proves parent-before-child directory admission succeeded; these Windows scenarios have not been executed. Source inspection and git diff --check completed. Tests, builds, typechecking, lint, and real-provider verification were skipped at the user's explicit request. Handled in 79f93f3. Removed the separate regex lookup. Launch release identity now uses the same parseGhidraJavaProperties owner as installation admission, reading ISO-8859-1 text and preserving escaped keys/values, continuations, colon separators, and last-key-wins overrides before selecting the release directory. Source inspection and git diff --check completed. Tests, builds, typechecking, lint, and real-provider verification were skipped at the user's explicit request. |
Problem
On Windows x64 the first Ghidra-backed query fails even though
rea doctorreports a validGhidra installation and 64-bit JDK. Ghidra's launch support cannot persist its JDK choice
inside REA's private runtime:
LaunchSupport then falls back to its interactive prompt, reads EOF, and prints
JDK 21+ (64-bit) could not be found and must be manually chosen!, so the provider failswith
Ghidra exited before bridge startup.Cause
createGhidraRuntimeDirectoriescreates the six runtime roots but not the launch-supportrelease directory Ghidra writes into. The private runtime's DACL lets the owning process
write, but the launched JVM does not create those directories itself, so
saveJavaHomethrows and JDK resolution aborts.
Fix
Create
<config>/ghidra/<release directory>before launch, one level at a time, while thisprocess still owns the runtime, so Ghidra only has to write a file inside it. The release
coordinate comes from the installation's
Ghidra/application.properties(
application.versionplusapplication.release.name), with the extraction directory nameas a fallback.
Validation
Windows x64, Ghidra 12.1.4, 64-bit Temurin JDK 21, REA's packaged native addon:
rea inspect <x64 PE DLL> --provider ghidra --format jsoncompletes and reports 21segments, 1436 procedures, and 2761 strings.
binary_overviewcall returns the same Evidence record.rea doctor --provider ghidrawas already healthy before this change, so the failure wasonly observable on the first real Ghidra query.
Reproduction
Observed on: Windows 10+ x64, Node.js 24.15.0, Ghidra 12.1.4 (official zip), 64-bit Temurin
JDK 21.0.12.1, native addon from the packaged artifact.
TEMP/TMPwere left at theirdefaults.
Build the parent commit with the pinned toolchain (
npm ci && npm run build:cached) andexport absolute paths:
Confirm the installation itself is accepted. This is healthy both before and after the
change, which is why the failure looked unrelated to setup:
Run the first Ghidra-backed query on any native x64 PE (EXE or DLL), using the documented
entry point from
docs/windows-ghidra-p0.md:Result:
execution_failure,failure_kind: "process",failure_message: "Ghidra exited before bridge startup". The retained diagnostics carrythe cause. stdout:
stderr:
The
askJavaHomeNPE is LaunchSupport falling back to its interactive prompt after thesaveJavaHomeIOException; there is no console, so it reads EOF and reports that nosupported JDK was found.
After this change the same command completes and
open_binary/binary_overviewreturnanalysis Evidence. Ghidra's launch support now resolves the JDK from
JAVA_HOMEandwrites
java_home.saveinto the pre-created directory itself:The same launch path is exercised by
npm run verify:ghidra:windows.Notes for review
created with plain
mkdirrather than the native private-runtime owner.itself, a pointer to where that is enforced would be welcome — pre-creating it is the
minimal change that unblocked the P0 path here.