Skip to content

fix: resolve critical lifecycle, admission, and analysis defects (#4475, #4483, #4490, #4494, #4495, #4509) - #4493

Closed
qorvr wants to merge 34 commits into
morluto:mainfrom
qorvr:fix/firmware-read-handle-cleanup
Closed

qorvr wants to merge 34 commits into
morluto:mainfrom
qorvr:fix/firmware-read-handle-cleanup

Conversation

@qorvr

@qorvr qorvr commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #4475, #4483, #4490, #4494, #4495

Summary of Defects & Key Changes

1. #4495: Apple Dyld Resolution File Admission & Descriptor Lifecycle

  • Root Cause: DylibResolutionReader.ts opened candidate Mach-O files with blocking O_RDONLY | O_NOFOLLOW (without O_NONBLOCK), causing MCP workers to hang indefinitely if candidate paths in dyld search routes were FIFOs or special devices. Candidate files were opened 3 times independently (startsWithMachoMagic, readImage, fileSha256), descriptor close failures in finally dropped descriptor ownership, and the outer catch masked underlying I/O errors if the abort signal triggered after the failure.
  • Fix: Switched admission to withOwnedRegularFile enforcing non-blocking flags (O_NONBLOCK | O_NOFOLLOW), guarding against FIFOs with NonRegularFileReadError, retaining unclosed descriptors into caller-provided ArtifactResourceScope for provider retry, preserving exact cancellation causes, and avoiding masking primary I/O failures.
  • Verification: Added regression tests in src/artifacts/apple/MachoLoadCommandReader.test.ts for FIFO named-pipe non-blocking handling and exact cancellation propagation.

2. #4494: Packaged Electron App (draw.io) Modal Dialog & Scenario Blocker

  • Root Cause: PlaywrightElectronActiveProvider.ts passed paths.application (app.asar) as a positional CLI argument. For packaged applications like draw.io or VS Code, the binary already packages the application, so passing the ASAR path causes the application to treat it as a user document to open on startup, triggering an "Invalid file" modal dialog that blocks declared scenario actions.
  • Fix: Omitted paths.application when paths.executable === paths.application, and updated scripts/electron-active-hook.cjs to sanitize process.argv on startup, removing internal REA flags and positional ASAR arguments under packaged binaries.
  • Verification: Unit tests in src/browser/PlaywrightElectronActiveProvider.test.ts verified argument construction and hook sanitization across packaged and unpackaged scenarios (24/24 passed).

3. #4483: Output Tree Readback Cancellation Assertion & Error Preservation

  • Root Cause: SafeOutputTreeReadback.ts:hashOutputFile() lacked a post-loop cancellation assertion. An aborted stream or zero-byte read could return successfully and validate against expected hashes instead of propagating cancellation, and masked original I/O errors (EIO) with cancellation.
  • Fix: Added isAborted() checks after the chunk read loop and after assertFilePathIdentity(), preserved { cause: signal.reason }, and prevented cancellation from masking preceding I/O errors.
  • Verification: Added regression tests in tests/boundary/filesystem/safeOutputTree.test.ts asserting cancellation failure reason and cause propagation (19/19 passed).

4. #4490: Webpack-Bundled External Destructuring Analysis Loss

  • Root Cause: In Webpack-bundled applications (e.g. Element, Joplin), external module requires (var ext = __webpack_require__('electron'); const { BrowserWindow } = ext;) failed identifier origin resolution because bindingOrigin() only checked direct require() calls and dropped identifier initializers.
  • Fix: Updated javascriptSemanticAnalysis.ts to trace identifier initializers using resolveSemanticBindingState with a visited cycle guard so destructured bindings inherit parent module origin (electron -> BrowserWindow).
  • Verification: Regression tests in src/domain/javascript/electronBundledRequireIdentity.test.ts confirmed BrowserWindow and ipcMain origin resolution (42/42 passed).

5. #4475: Firmware Read Handle Close Failure Retention

  • Root Cause: When closing regular file handles failed in firmware report reads or snapshotting, descriptor close errors dropped handle ownership and discarded completed partial observations.
  • Fix: Retained unclosed descriptors in PendingFirmwareCleanup.descriptors, enabled retries via provider.close(), and attached partialObservation on descriptor cleanup errors.
  • Verification: Regression tests in tests/boundary/firmware/firmwareReportFiles.test.ts and tests/boundary/firmware/firmwareWorkspaceRecovery.test.ts (45/45 passed).

Verification

  • npm run check:fast passed (turborepo typecheck & lint, 0 errors, 0 warnings).
  • All unit and boundary regression tests passing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-18T02:47:50.155205Z f1dbdf9 Manual request
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a non-blocking loss of detail in Ghidra Java probe errors.

Findings

  1. P2 Java errors lose their explanation ▶
Fix with agent prompt
### Issue 1
src/ghidra/GhidraInstallation.ts:571-578
`installationCoordinates` drops the Java probe's diagnostics when it converts an `AnalysisError` into `GhidraJavaProbeFailure`. A failed macOS ownership-helper build records `stage: "ownership_preparation"` and `compiler_outcome`, but this conversion keeps only the generic adapter message and captured output. Users then see a Java runtime failure without the stage or compiler result that explains it.

Preserve those diagnostics in the installation failure and its caller-facing output.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR updates Electron launch arguments and manifest reads, JavaScript alias and path analysis, packet errors, firmware publication errors, and command admission.

  • Packaged Electron apps launch without their bundled app path.
  • Cutter and Rizin reject commands with embedded line breaks or NULs.
  • Webpack analysis follows Electron modules through destructured aliases.
  • ESM path resolution checks locality before normalizing URL text.
  • TShark packet errors keep the captured output that explains them.
  • Firmware cleanup errors retain owned resources and published results.
  • Ghidra reports ordinary Java probe failures as runtime details.
  • File buffers are cleared while APK locale checks keep the same results.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Electron capture] --> B[Check executable fuses]
  B --> C[Check whether executable bundles the app]
  C --> D[Read bounded manifest when needed]
  D --> E[Build launch arguments]
  E --> F[Launch and run actions]
  F --> G[Close processes and transport]
  D --> H[Retain handles that fail to close]
  G --> H
  H --> I[Retry owned resources on close]
Loading

Reviews (28) · Last reviewed commit: "chore(merge): align with upstream main (..." · Reviewed by Greptile

Comment thread src/firmware/FirmwareProvider.ts Resolved
Comment thread src/firmware/FirmwareProvider.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: de28a8f832

ℹ️ 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/firmware/FirmwareProvider.ts Outdated
Comment on lines +171 to +175
} catch (cause: unknown) {
failures.push(
new ProviderCleanupError(
info.engine,
[info.path],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Block admission while descriptor cleanup remains unresolved

When the same descriptor close continues to fail on the next execute(), this catch only appends a cleanup failure; processUnverified remains false, and the caller ignores cleanup.failure unless that process flag is set. The provider therefore starts command resolution and snapshotting while the old handle is still pending, so repeated requests can open additional descriptors and launch native work instead of retrying the exact owner exclusively. Make unresolved descriptor cleanup block admission just like the lifecycle contract requires.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread src/firmware/FirmwareProvider.ts Outdated
Comment on lines +168 to +170
try {
await owner.close();
this.#unrootedDescriptors.delete(owner);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve cleanup errors when descriptor retries succeed

After a retained handle eventually closes, this path only removes it from the map; none of the ProviderCleanupError instances returned for that owner are bound to the retry or have resolveCleanup() called. For example, provider.close() can succeed after a report-close failure while the original operation error still projects as cleanup_incomplete with stale resources. Retain a cleanup lease for each descriptor and bind every originating or aggregate error so successful release resolves its live cleanup marker.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread src/firmware/FirmwareProvider.ts Outdated
Comment on lines +243 to +245
await pending.root.close();
if (pending.tree === undefined) this.#pendingCleanup.delete(path);
if (pending.tree === undefined && pending.descriptors.size === 0)
this.#pendingCleanup.delete(path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep workspace roots until descriptor release succeeds

If a rooted report or extraction descriptor still fails to close in the preceding retry loop, this block nevertheless calls PrivateRuntimeRoot.close(). On POSIX that method recursively removes the workspace successfully even with an open file descriptor, so the child remains unresolved while its containing root and reported paths disappear; later retries retain only an unlinked handle. Skip tree/root cleanup until pending.descriptors is empty so child release is confirmed before parent removal.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread src/firmware/FirmwareProvider.ts Outdated
request: FirmwareRequest,
descriptors?: Map<OwnedFileHandle, string>,
): Promise<Outcome> => {
if (outcome.ok && descriptors !== undefined && descriptors.size > 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Report retained descriptors on failed operations

When snapshotFirmware or its selected-range hash retains a failed close, the thrown RegularFileCleanupFailure is converted by the outer catch into an ordinary failed outcome, so this success-only descriptor branch is skipped and the later cleanupIncomplete branch is skipped as well. The workspace is then closed and the caller receives an error claiming cleanup is complete even though the descriptor remains in pending.descriptors. Compose retained descriptor cleanup with failed outcomes as well as successful ones so the handle path and primary failure both survive.

AGENTS.md reference: AGENTS.md:L31-L31

Useful? React with 👍 / 👎.

@qorvr qorvr changed the title fix(firmware): retain descriptor ownership and typed outcome on close failure fix: resolve critical lifecycle, admission, and analysis defects (#4475, #4483, #4490, #4494, #4495) Oct 16, 2026

@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: e03e0237cd

ℹ️ 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".

targetSha256: this.target.sha256,
enumerateRoots: bundle !== undefined,
parameters,
resourceScope: this.#resourceScope,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Run dyld traces inside the resource scope

When a trace_dylib_resolution descriptor close has been retained, a subsequent trace reaches this call directly rather than through ArtifactResourceScope.run(). The dispatch at ArtifactProvider.ts:184-185 confirms that only the inventory/extraction helpers enter the scope, while run() is what retries #pending before admission and registers work in #active; repeated trace requests can therefore open more descriptors while prior cleanup remains unresolved, and a direct close() cannot see the active trace. Execute the complete trace within the scope instead of merely passing the scope down.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

cause.outcome.kind === "failed"
? cause.outcome.cause
: new ArtifactReaderFailure("unavailable", cause.message, { cause });
throw ArtifactReaderFailure.withCleanup(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind dyld cleanup errors to retained owners

When a retained dyld handle later closes successfully in ArtifactResourceScope.retryCleanup() or close(), this path has already reduced the owner to a static cleanup observation; neither the scope nor translateArtifactFailure() keeps a lease to the resulting ArtifactOperationError. The original error therefore remains cleanupIncomplete and continues naming a resource that was released. Retain an AnalysisCleanupLease per descriptor and bind the originating and retry errors before discarding the owner.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment on lines +307 to +311
retainFailedClose: (owner) => {
resourceScope?.retain({
kind: "file-handle",
resource: path,
handle: owner,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Report every concurrently retained dyld descriptor

When two or more of the eight concurrent bundle magic reads fail descriptor close, each callback retains its owner here, but consumeWithOrderedReads() throws only the first ordered failure and its finally merely awaits the remaining settled records. The catch at lines 192-203 consequently reports one path even though #resourceScope owns all failed handles, so the operation's cleanup resources are incomplete. Aggregate every retained child or lease into the returned cleanup error.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread scripts/electron-active-hook.cjs Outdated
const arg = process.argv[index];
if (
typeof arg === "string" &&
(arg.endsWith(".asar") || arg.includes(".asar/"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve caller-supplied ASAR arguments

For packaged apps (process.defaultApp === false), this removes every argument ending in .asar or containing .asar/, not just the launcher-owned application token. PlaywrightElectronActiveProvider appends the caller's unconstrained input.args to the same argv, so an app invoked with /tmp/plugin.asar or --config=/tmp/app.asar/settings silently receives different inputs and the experiment can exercise the wrong behavior. Track and remove the exact injected application argument instead of pattern-matching all argv entries.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

Comment on lines +192 to +196
if (cause instanceof RegularFileCleanupFailure) {
const primary =
cause.outcome.kind === "failed"
? cause.outcome.cause
: new ArtifactReaderFailure("unavailable", cause.message, { cause });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve late dyld cancellation through close failure

When the abort signal fires after a dyld file operation completes but while its descriptor close fails, withOwnedRegularFile() throws RegularFileCleanupFailure with a completed outcome. This branch converts that case to unavailable; the preceding cancellation classifier does not recognize the cleanup wrapper even though the signal is now aborted, so the caller's cancellation and exact reason disappear. Use typed cancellation as the primary error and attach the cleanup observation and completed facts.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread src/firmware/FirmwareCommand.ts Outdated
},
{ cause: failure, operation },
);
if (failure.outcome.kind === "completed") return cleanup;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve late firmware cancellation through close failure

When the caller aborts after a report read completes but the descriptor close fails, failure.outcome.kind is completed, so this unconditional return emits only ProviderCleanupError. readFirmwareCommandReport() then carries completedReport forward and FirmwareProvider never rechecks the signal, causing an explicitly cancelled inspection or extraction to project as cleanup-only instead of typed cancellation with the retained observation. Pass the signal into this composition and preserve cancellation as the primary failure.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread scripts/electron-active-hook.cjs Resolved
Comment thread src/firmware/FirmwareCommand.ts Resolved
@qorvr

qorvr commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

1 similar comment
@qorvr

qorvr commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 77d59c72e4

ℹ️ 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 scripts/electron-active-hook.cjs Outdated
Comment on lines +606 to +609
normalized.endsWith("/electron-active-hook.cjs") ||
normalized.endsWith("/electron-active-hook.js") ||
normalized === "electron-active-hook.cjs" ||
normalized === "electron-active-hook.js"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match only the injected Electron hook path

The ASAR-specific filter is gone, but when the selected default application or any caller-supplied argument is a different file named electron-active-hook.js or .cjs, these suffix branches still classify it as REA's hook and splice it (and possibly a preceding -r) from process.argv. Since PlaywrightElectronActiveProvider appends unconstrained input.args, this changes the experiment's inputs or can remove the application entry itself; compare only against the exact injected hook argument.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

Comment thread src/firmware/FirmwareProvider.ts Outdated
: { partialObservation: outcome.error.partialObservation }),
},
);
new AnalysisCleanupLeaseGroup(cleanup, descriptorLeases);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Delay descriptor resolution until parent cleanup succeeds

When an otherwise successful operation retains a descriptor, this binds the returned cleanup error only to descriptor leases even though that error also reports the workspace root. On retry, AnalysisCleanupLease.release() resolves the original caller-visible error before root.close() runs; if root removal then fails, the provider retains the root and emits a new error while the original error now falsely projects cleanup as complete. Keep the marker unresolved until the ordered parent cleanup also succeeds.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread src/firmware/FirmwareCommand.ts Outdated
Comment on lines +70 to +73
if (
abortSignal?.aborted ||
(failure.outcome.kind === "failed" &&
failure.outcome.cause instanceof AnalysisCancelledError)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve firmware failures through late cancellation

The completed-report case from the earlier review is different from this fresh failing-outcome path: when report parsing or another file operation has already failed and the caller aborts only while descriptor close also fails, abortSignal.aborted unconditionally replaces the established output/I/O failure with cancellation. Preserve failure.outcome.cause as primary unless that cause is itself cancellation; use signal-only late cancellation only for a completed outcome.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment on lines +193 to +195
options.signal?.aborted ||
(cause.outcome.kind === "failed" &&
isCancellationError(cause.outcome.cause, options.signal))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve dyld failures through late cancellation

The earlier completed-read case now gets typed cancellation, but a fresh failing-outcome case remains: if a Mach-O read has already failed with an integrity or I/O error and the signal aborts only while descriptor close also fails, the signal-only arm selects cancellation and discards cause.outcome.cause. Restrict that arm to completed outcomes so an already-established primary failure remains primary with cleanup attached.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread src/firmware/FirmwareProvider.ts Resolved
@qorvr

qorvr commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/rust/RustBinaryProvider.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: 8622810e8e

ℹ️ 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/rust/RustBinaryProvider.ts Outdated
RUST_BINARY_PROVIDER_IDENTITY.id,
cause.cleanup.resources,
{ reason: cause.cleanup.reason },
{ operation: OPERATION, cause },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Put retained Rust descriptors in a retryable scope

When readStableArtifact cannot close its descriptor, this stores the owner only through the returned error's cause; RustBinaryProvider has no resource scope and RustBinaryPort exposes no close(), so the persistent server service cannot retry that owner and subsequent inspections can open additional descriptors. Retain it in provider-owned state with retry-before-admission and final-close behavior instead of relying on callers to traverse an error cause.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Comment thread src/rust/RustBinaryProvider.ts Outdated
Comment on lines +161 to +165
return new AnalysisCancelledError(OPERATION, {
cause: new AggregateError(
[new AnalysisCancelledError(OPERATION), cleanup],
"Cancelled with cleanup",
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep cleanup incomplete on late Rust cancellation

When the signal fires while descriptor close rejects, this returns an AnalysisCancelledError whose only reference to ProviderCleanupError is inside AggregateError.cause; the top-level error therefore has cleanupIncomplete === false, and normal projections omit the still-open descriptor path. Compose cancellation with the cleanup failure (or attach its cleanup observation) so late cancellation does not falsely report completed cleanup.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread src/rust/RustBinaryProvider.ts Outdated
"Cancelled with cleanup",
),
});
return cleanup;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve Rust read failures alongside cleanup

When the file operation itself has already failed (for example with an integrity or size-limit failure) and descriptor close also fails, cause.cleanup enters this branch and the unconditional return reports only cleanup, even though the typed primary is retained in cause.outcome. Build the normal Rust analysis error from the failed outcome and compose it with cleanup, reserving a bare cleanup error for a completed read.

AGENTS.md reference: AGENTS.md:L31-L31

Useful? React with 👍 / 👎.

Comment thread src/firmware/FirmwareProvider.ts Outdated
pending.engine,
[path, pending.tree?.outputRoot ?? path],
{ reason: cause instanceof Error ? cause.message : String(cause) },
[entry.path],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report the retained firmware workspace on retry

When a descriptor belonging to a firmware workspace still fails to close during retry, the workspace root is deliberately kept in #pendingCleanup because the parent cleanup below runs only after descriptors.size reaches zero, but this retry error names only entry.path. A subsequent execute() or close() therefore omits an owned residual workspace from cleanupResources; include the pending root path in this failure as the initial operation error does.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@qorvr
qorvr force-pushed the fix/firmware-read-handle-cleanup branch from 8622810 to 8ee0a28 Compare October 16, 2026 17:19
@qorvr qorvr changed the title fix: resolve critical lifecycle, admission, and analysis defects (#4475, #4483, #4490, #4494, #4495) fix: resolve critical lifecycle, admission, and analysis defects (#4475, #4483, #4490, #4494, #4495, #4509) Oct 16, 2026
@qorvr

qorvr commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@greptile review

@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: 8ee0a28c92

ℹ️ 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".

initializer.node.name,
);
if (targetBinding !== undefined) {
const parentOrigin = bindingOrigin(targetBinding, state, visited);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bound alias-origin traversal before recursing

When an analyzed bundle contains a long stable alias chain (for example, thousands of const aN = aNMinus1 declarations ending in one Electron use), this recursive call consumes one JavaScript stack frame per alias. The new visited set only stops cycles, so a valid chain within accepted source limits can raise RangeError: Maximum call stack size exceeded and abort analysis instead of returning bounded or unknown evidence; walk the chain iteratively (and preferably memoize origins) or enforce a reported depth limit.

AGENTS.md reference: AGENTS.md:L51-L52

Useful? React with 👍 / 👎.

@qorvr

qorvr commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@greptile review

@qorvr

qorvr commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@qorvr

qorvr commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@greptile review

@qorvr

qorvr commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@qorvr

qorvr commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@greptile review

@qorvr

qorvr commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 2f298b7c3d

ℹ️ 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".

const isWithin = isDarwinOrWin
? isPathWithinRoot(normRoot.toLowerCase(), normApp.toLowerCase())
: isPathWithinRoot(normRoot, normApp);
if (!isWithin) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor package mains outside the bundle root

When an unpacked packaged app declares a valid entry such as "main": "../launcher.js" (or an absolute path) and application_path selects that file, Electron resolves and launches it from resources/app/package.json, but this early containment return prevents the manifest from being inspected. capture() then appends the already-loaded entry as a positional argument, so applications that interpret positionals as documents or URLs run a different scenario; inspect the package entry before rejecting an out-of-root selected path.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

@qorvr

qorvr commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@greptile review

@qorvr

qorvr commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@qorvr

qorvr commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@greptile review

@qorvr

qorvr commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Comment on lines +571 to +578
? javaProbe.error instanceof AnalysisError
? {
_tag: "GhidraJavaProbeFailure",
code: "runtime_unavailable",
detail: `${javaCommand}: ${javaProbe.error.userMessage ?? javaProbe.error.message}`,
...(javaProbe.error.capturedOutput === undefined
? {}
: { output: javaProbe.error.capturedOutput }),

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.

P2 Java errors lose their explanation

installationCoordinates drops the Java probe's diagnostics when it converts an AnalysisError into GhidraJavaProbeFailure. A failed macOS ownership-helper build records stage: "ownership_preparation" and compiler_outcome, but this conversion keeps only the generic adapter message and captured output. Users then see a Java runtime failure without the stage or compiler result that explains it.

Preserve those diagnostics in the installation failure and its caller-facing output.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ghidra/GhidraInstallation.ts
Line: 571-578

Comment:
**Java errors lose their explanation**

`installationCoordinates` drops the Java probe's diagnostics when it converts an `AnalysisError` into `GhidraJavaProbeFailure`. A failed macOS ownership-helper build records `stage: "ownership_preparation"` and `compiler_outcome`, but this conversion keeps only the generic adapter message and captured output. Users then see a Java runtime failure without the stage or compiler result that explains it.

Preserve those diagnostics in the installation failure and its caller-facing output.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@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: f1dbdf9ff5

ℹ️ 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".

initializer.node.name,
);
if (targetBinding !== undefined) {
const parentOrigin = bindingOrigin(targetBinding, state, visited);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check initialization order before following aliases

When an alias is initialized before a hoisted var receives its module value (for example, var alias = electron; var electron = require("electron")), this recursive hop asks bindingOrigin() for the target's eventual initializer without comparing source positions. alias actually captured undefined, but guarded uses such as alias && new alias.BrowserWindow() are now reported as Electron evidence; require the target origin to be established before the alias initializer, otherwise retain unknown provenance.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

@CassieFox23 CassieFox23 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.

TL;DR: The maintainer closed three of the five issues the PR names (#4475, #4483, #4495). The PR's diff no longer touches the files its body says fix them. Only #4490 and #4494 are still open, and the PR's tests for them pass on Node 22, 24 and 26. The one P1 thread on the current head is already handled.

Issues the PR names

Issue State now What I found
#4475 closed, completed not in this PR's diff; commit 2d163c1 ("Refs #4475") is in the PR base
#4483 closed, completed not in this PR's diff; commit 542fa84 ("Refs #4458, #4483") is in the PR base
#4495 closed, completed not in this PR's diff; commit d292c44 ("Refs #4495") is in the PR base
#4490 open the fix is in this PR (javascriptSemanticAnalysis.ts) and not on main
#4494 open the fix is in this PR (Electron provider and hook) and not on main

The PR body also lists tests for the first three, such as safeOutputTree.test.ts and firmwareReportFiles.test.ts. None of those files is in the diff against the base. So the body and the diff no longer match. GitHub shows the three issues closed as completed by the maintainer. No commit is attached. I did not check why; I only read the issue state, the close events and the commit messages.

Findings and verdicts

Head is f1dbdf9. Base is b33c0df. Main is 92dadf9. Bot threads: 38 unresolved, 15 P1 and 23 P2. This table covers the P1s. "Not real at head" means I ran a check and it passed.

Thread Claim Verdict What I saw
4 threads on FirmwareProvider.ts (also r4295469220, r4295469228, r4295469239) Cleanup and descriptor retention Moot at head FirmwareProvider.ts is byte-identical to main (cmp exit 0) and not in the diff
ArtifactProvider.ts Run dyld traces in the scope Moot at head Byte-identical to main (cmp exit 0) and not in the diff
DylibResolutionReader.ts and second thread Dyld cleanup owners Moot at head Byte-identical to main (cmp exit 0) and not in the diff
RustBinaryProvider.ts and second thread Rust descriptor retry Moot at head Byte-identical to main (cmp exit 0) and not in the diff
Hook drops caller ASAR args The hook strips every .asar argument Not real at head The hook has no asar filter now; electronActiveHook.test.ts passes
Package probe can block A FIFO at package.json hangs Not real at head A FIFO there is rejected as target_not_allowed in 0 to 1 ms on Node 22, 24 and 26
Failed probe close lost A failed close is not retained Not real at head The test at line 1108 of PlaywrightElectronActiveProvider.test.ts passes
Manifest read outside the scope Read skips the resource scope Not real at head (code read, not run) capture() runs inside #resources.run() at line 314
Provider not closed on shutdown Nothing calls close() Not real at head (code read, not run) transport.ts line 88 and createServer.ts line 407 reach close()
Cleanup lost on cancellation Abort hides a failed close Not real at head I aborted mid-read with a close that always fails: cleanup_failed, cleanupIncomplete: true, scope still pending; provider.close() then clears it. Same on Node 22, 24 and 26

Passing tests: 14 files, 402 tests, same on Node 22.23.1, 24.18.0 and 26.11.1. They cover:

  • The Electron provider, hook and cleanup tests
  • electronBundledRequireIdentity
  • JavaScriptArtifactPathResolution
  • singleCommandLineSchema
  • packetOutput
  • The cutter and rizin tests
  • Two Ghidra tests

Not run

  • The 23 P2 threads. Nine are on the current head, such as alias-chain depth, BOM handling and package main fallbacks. I did not probe them.
  • A live Electron capture of the draw.io case from #4494. Only unit tests ran.
  • Typecheck and lint, and the full suite.
  • Why the maintainer closed #4475, #4483 and #4495.
  • The extra files in the diff (cutter, tshark, Ghidra, apktool). Only their test files ran, and I skipped the Ghidra CLI test because it runs doctor.

The PR sits on a 6.5.0 base and main is at 6.7.0. If the PR is rebased, a short body that lists only #4490 and #4494 would match the diff.

Thanks, qorvr, for the Electron and Webpack fixes. I hope this makes the bot threads easier to read.

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: f1dbdf9 / b33c0df (main was 92dadf9 at start and end)
  • Other: the box was shared with other test jobs, so I report no timings.
Commands
npm ci --ignore-scripts; npm run prepare; npm run build:cached; npm run test:prepare   (Node 24, tree at f1dbdf9ff)
npm run test:focused -- src/application/javascript/JavaScriptArtifactPathResolution.test.ts \
  src/browser/PlaywrightElectronActiveProvider.test.ts src/contracts/singleCommandLineSchema.test.ts \
  src/domain/javascript/electronBundledRequireIdentity.test.ts \
  tests/boundary/browser/electronActiveCleanup.test.ts tests/boundary/browser/electronActiveHook.test.ts \
  tests/boundary/captures/packetOutput.test.ts tests/boundary/cli/cutterCommands.test.ts \
  tests/boundary/cli/reverseEngineeringCommands.test.ts tests/boundary/mcp/cutterMcp.test.ts \
  tests/boundary/mcp/rizinDebuggerCancellationMcp.test.ts tests/boundary/providers/CutterBridgeService.test.ts \
  tests/boundary/filesystem/ghidraJavaProbe.test.ts tests/boundary/filesystem/ghidraInstallationProperties.test.ts
  (once each on Node 24, 22 and 26)
cmp <head tree>/src/artifacts/apple/DylibResolutionReader.ts <main tree>/src/artifacts/apple/DylibResolutionReader.ts
  (and ArtifactProvider.ts, FirmwareProvider.ts, FirmwareCommand.ts, RustBinaryProvider.ts, SafeOutputTreeReadback.ts)

Two small probe tests of my own (abort during the package.json read with a failing close, and a FIFO at package.json) ran through the same test:focused command. None of the test files mentions doctor except the Ghidra CLI one, which I skipped.

All 38 unresolved threads (P2 included)

P1 rows are in the table above. P2 threads, none probed:

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

@Rinkia

Rinkia commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

TL;DR: The #4490 part works end to end. With this PR, the six fixtures from #4490 and Bitwarden desktop 2026.10.0 report the destructured handlers and window. [email protected] and current main still miss them. It also holds when the JavaScript change is merged onto current main. Thanks, qorvr.

This adds CLI runs on real inputs to CassieFox23's unit-test review above. I only tested #4490, not #4494 or the other files.

Builds: [email protected] (npm); main 074768901; this PR's head f1dbdf9ff; and main 074768901 with this PR's javascriptSemanticAnalysis.ts and electronBundledRequireIdentity.test.ts taken from git merge-tree ("merged" below). That file merges cleanly. The PR's only conflict with main is in src/browser/PlaywrightElectronActiveProvider.test.ts (the #4494 part). Built with npm ci --ignore-scripts && npm run compile on Node 24.22.0.

Fixtures from #4490 (rea analyze-javascript-application <dir> --format json; the columns are summary.browser_windows, explicit_web_preferences, ipc.operations and ipc.main_handlers):

Fixture 6.7.0 main PR head merged
A: require("electron") + destructure 0/0/1/1 0/0/1/1 0/0/1/1 0/0/1/1
D: external, member access 0/0/1/1 0/0/1/1 0/0/1/1 0/0/1/1
B: external + const {app, ipcMain} = … 0/0/0/0 0/0/0/0 0/0/1/1 (chan-b) 0/0/1/1
C: B with the handler inside a guarded arrow 0/0/0/0 0/0/0/0 0/0/1/1 (chan-c) 0/0/1/1
F: new external_electron_.BrowserWindow(…) 1/2/0/0 1/2/0/0 1/2/0/0 1/2/0/0
E: const {BrowserWindow} = …; new BrowserWindow(…) 0/0/0/0 0/0/0/0 1/2/0/0 1/2/0/0

With the fix, E's window carries the same webPreferences as F, including nodeIntegration: true.

Bitwarden desktop 2026.10.0 (Bitwarden-2026.10.0-amd64.deb, sha256 fcabfc7d…063f; app.asar with --source-path main.js --source-path preload.js):

windows webPrefs IPC ops main handlers literal main channels
6.7.0 1 7 145 50 33 of 34
main 074768901 1 7 145 50 33 of 34
PR head 1 7 146 51 34 of 34
merged 1 7 146 51 34 of 34

The only channel added is electron-store-get-data, the one from electron-store's const {app, ipcMain, shell} = external_electron_ in #4490. Nothing else changed in the channel list.

Unit test: the PR's version of electronBundledRequireIdentity.test.ts fails on main 074768901 (3 failed, 41 passed). The failures are the three new destructuring/alias cases. With the change it passes 44/44 ("merged").

Not covered: #4494 and the other files in the diff, the P2 threads (for example alias-chain depth), and computed-key or rest-element patterns. For the last, #4490 asked for an unknown rather than silence; I did not test whether one is reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

4 participants