Skip to content

fix(ghidra): keep JVM warnings out of LaunchSupport output - #1698

Merged
morluto merged 5 commits into
morluto:mainfrom
Petru101:fix/ghidra-launchsupport-jvm-warnings
Oct 12, 2026
Merged

morluto merged 5 commits into
morluto:mainfrom
Petru101:fix/ghidra-launchsupport-jvm-warnings

Conversation

@Petru101

@Petru101 Petru101 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On POSIX, REA parses Ghidra LaunchSupport stdout as environment entries and JVM arguments. HotSpot unified-logging warnings can corrupt that output and prevent Ghidra sessions from opening. The reported reproduction uses Ubuntu 24.04 distrobox, Ghidra 12.1.4, and JDK 21.0.12, where a cgroup namespace warning produces Invalid Ghidra LaunchSupport environment entry.

For an identified HotSpot VM, both LaunchSupport probes now use -Xlog:disable -Xlog:all=warning:stderr. VM identity comes from java.vm.name in the existing installation probe. OpenJ9, unrecognized VMs, and unavailable VM identity preserve their previous helper arguments. Successful helper stderr is retained in session diagnostics under launch_support, with its probe mode, original byte count, and truncation status. Completed probe warnings also survive parsing errors, later helper failures, cancellation, and incomplete cleanup. Retention uses the existing 8 KiB per-stream diagnostic budget and redacts the session transport credential before truncation.

The analysis JVM arguments and Windows script launch are unchanged. CLI/MCP tool contracts and installation behavior are unchanged; diagnostics gain helper stderr and observed VM identity. Existing process ownership and cleanup responsibilities are preserved.

Review fixes

  • Addressed the review thread about silently discarded successful helper stderr.
  • Fixed the follow-up cancellation/timeout projection loss: diagnostics are retained by the shared analysis-error context and forwarded through every Ghidra typed mapping. Removed adapter-only diagnostic storage and projection.
  • Updated the existing explicit-sensitive-value redactor to preserve sanitized shared context, captured-output metadata, and cleanup facts. Replaced the cancellation test that bypassed provider projection with actual GhidraClient/provider regressions and serialized error-contract validation for caller cancellation and startup deadline.
  • Addressed the additional OpenJ9 compatibility thread by selecting flags from parsed VM identity without adding a launch-time probe. OpenJ9 documents different -Xlog semantics.
  • Replaced the fixture that suppressed warnings with one that emits them on stderr and verifies launcher diagnostics through success and failure paths.
  • Merged main into the branch without conflicts.

Validation

  • Ghidra focused suite: 28 files, 512 passed, 1 skipped.
  • npm run check:ci, npm run docs:check, and npm run verify:test-discovery: passed; all 951 test files discovered exactly once.
  • Launcher regressions cover both helper modes, malformed output, later command failure, bounded UTF-8 retention, explicit credential redaction, preservation of caller paths, and cancellation after process creation. Java-probe and provider tests verify VM identity parsing and forwarding; helper tests cover HotSpot, OpenJ9, unrecognized, and missing identities.
  • Real Ghidra 12.1.4 with Temurin 21.0.12.1 on macOS arm64: launched an ephemeral analysis, listed two procedures, retained real JVM warnings after client close, and confirmed the target digest was unchanged. The launcher used VM identity observed by the real installation probe. A temporary Java wrapper enabled an unsupported large-page option for the helper probes to produce real JVM stderr; the analysis JVM used its original arguments.
  • Real Ghidra 12.1.4/Temurin 21.0.12.1 on macOS arm64 also retained both helper warning records through the provider-neutral, JSON-serialized cancellation and timeout errors. This run used actual LaunchSupport probes and an owned analysis JVM, with abort/deadline injected after process creation; cleanup was confirmed and the target digest stayed unchanged.
  • Linux distrobox/cgroup before-and-after verification was reported by the contributor and an independent tester. The additional macOS run verifies warning retention with the real provider; it does not reproduce the Linux cgroup condition or establish Windows behavior. OpenJ9 flag selection is fixture-backed; a real OpenJ9 provider run was not performed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T18:43:07.087586Z 8cfa45f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2375690842

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/ghidra/GhidraJavaLaunch.ts Resolved
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: Fixed: a HotSpot warning on standard output no longer breaks the Ghidra launch. With real Ghidra 12.1.4, the base commit failed and this PR passed. Still open: the warning now goes to stderr, and REA throws it away.

Thanks, Petru101, for the fix and for the clear report.

Results

Base is 17f7040, where the PR branched. Head is 2375690.

Check Base Head
Real Ghidra call on a small ELF, with the real cgroup warning failed, exit 1 passed, exit 0
Launch code alone, same warning threw an error passed
Launch code alone, JAVA_TOOL_OPTIONS=-XX:+UseLargePages threw an error passed
Clean launch, no warning exit 0 exit 0, same output as base
New test on Node 24.18.0 failed not applicable
Patch on main e36c82b and on newer main 844fa52 not applicable applies clean on both

Base throws an error about a bad LaunchSupport entry. The CLI shows "Ghidra headless launch failed". On a clean launch, the output files have the same sha256 (191efda12d91 prefix) and the JVM arguments match, 32 of 32.

New test file, on head Node 22.23.1 Node 24.18.0 Node 26.11.1
The one test pass pass pass

Which warning lands on stdout. HotSpot's own log lines, like [warning][os,container] and [warning][pagesize], go to stdout. The "Picked up JAVA_TOOL_OPTIONS" banner goes to stderr, so it is harmless.

Why the real run needed a cgroup trick. REA clears JAVA_TOOL_OPTIONS, _JAVA_OPTIONS and JDK_JAVA_OPTIONS before it starts Ghidra. With JAVA_TOOL_OPTIONS=-XX:+UseLargePages set, base passed through the CLI, exit 0. So I made the report's warning another way. I ran the command in its own cgroup namespace, then moved it to a sibling cgroup. No container and no root were needed. The JVM then printed the same cgroup warning as the report, with a different path.

One more thing. On head, that warning shows up nowhere in the CLI output. A search of the head logs for "Cgroup" found nothing. This matches the Codex review note. The stderr text is captured and then dropped.

Not run

  • The distrobox (Ubuntu 24.04) setup from the report. The namespace trick above stands in for it.
  • The PR's own wider list: 20 test files, check:fast, verify:test-discovery.
  • Head with JAVA_TOOL_OPTIONS through the CLI. REA clears that variable anyway.
  • Windows, macOS, and any JDK other than 21.0.12.1.
Commands
# real warning on stdout, plain JVM
java -XX:+UseLargePages -version

# cgroup warning: run inside a delegated user scope (cgrun.sh moves the child to a sibling cgroup)
systemd-run --user --scope -q -p Delegate=yes -- cgrun.sh run-ghidra.sh base base-cgroup X=1
systemd-run --user --scope -q -p Delegate=yes -- cgrun.sh run-ghidra.sh head head-cgroup X=1

# run-ghidra.sh runs this inside the tree:
node scripts/rea.mjs analyze /tmp/pr1698/elf/hello --provider ghidra --format json

# launch code only
node direct-launch.mjs /tmp/pr1698/base
JTO=-XX:+UseLargePages node direct-launch.mjs /tmp/pr1698/head

# new test file, one run per Node (that Node first on PATH)
node scripts/run-development-tests.mjs focused tests/boundary/providers/ghidra/ghidraJavaLaunch.test.ts

# patch check on main
git diff 17f704050 237569084 | git apply --check

The test program is a six-line C file: gcc -O0 -o hello hello.c.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head / base: 2375690 / 17f7040 (the commit the PR branched from)
  • Ghidra: 12.1.4 (Apache-2.0)
  • JDK: Temurin 21.0.12.1
  • JDK licence: GPL-2.0-only
  • JDK extra: the Classpath exception applies
  • Compiler: gcc 16.2.1
  • Other test agents shared the box during these runs.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@dandgabr dandgabr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidated review

  • P2 — Preserve JVM warnings in launch diagnostics. GhidraJavaLaunch.ts now directs JVM warnings to stderr, but both execFileOutput call sites consume only .stdout and discard .stderr. This hides warnings such as cgroup/resource-limit diagnostics from the launch result. Capture and surface the redirected stderr while keeping the machine-readable LaunchSupport output parseable. This consolidates the still-applicable inline finding; no additional actionable findings were confirmed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 211c806b96

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ghidra/GhidraJavaLaunch.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcb7173938

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ghidra/GhidraLauncher.ts Resolved
@morluto
morluto merged commit e20994a into morluto:main Oct 12, 2026
36 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
3 tasks done
@morluto

morluto commented Oct 12, 2026

Copy link
Copy Markdown
Owner

@Petru101, thank you for tracking down how HotSpot’s warning output could break Ghidra’s machine-readable LaunchSupport response. Keeping the helper diagnostics while applying JVM flags only when the VM is identified makes the fix useful without assuming OpenJ9 behaves the same way. Welcome to REA!

@Petru101

Copy link
Copy Markdown
Contributor Author

Thank you :)

@Petru101
Petru101 deleted the fix/ghidra-launchsupport-jvm-warnings branch October 12, 2026 19:06
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto added the provider: ghidra Analysis provider / engine: ghidra label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants