Skip to content

Collect garbage before the java-web command exits, which avoids a hang in node's exit teardown - #44

Merged
Project516 merged 1 commit into
masterfrom
p516/exit-gc
Nov 5, 2026
Merged

Project516 merged 1 commit into
masterfrom
p516/exit-gc

Conversation

@Project516

Copy link
Copy Markdown
Owner

java/math/BigInteger/BitLengthOverflow.java timed out at 600 s in about one CI run in three, so #40 took it out of passing.txt. The test is fine. The java-web process hangs while exiting.

On GitHub's x64 runners, running the test four at a time as a CI shard does:

  • About 40% of runs printed both expected lines (Overflow reported by ArithmeticException, as expected), so main had returned, and then the process never exited.
  • A hung process had three threads left, node-MainThread, node-V8Worker and SignalInspector, all asleep in futex_do_wait, and did not answer a diagnostic report signal. It is stuck in node's own exit teardown, after process.exit. The test leaves several hundred MB of BigInteger arrays (array buffers) alive at exit.
  • It never happened on a small ARM board.

The java-web command now runs a full collection just before process.exit, so node's teardown does not have to free those buffers itself. Same runners, 20 runs each:

Variant Hung
As on master 5 of 20 (8 of 20 in an earlier run)
gc exposed at node startup instead of at runtime 6 of 20
Collection before process.exit (this PR) 0 of 20
node's --trace-exit (for comparison) 0 of 40

The collection only runs in the command's exit path. Library use (runNode, startLibrary) is unchanged. BitLengthOverflow goes back into passing.txt and times.tsv.

Checks:

  • Exit codes still come through: System.exit(0), 1 and 2.
  • pnpm typecheck passes. CI runs every OpenJDK test, since the PR changes src/node.ts.

…g in node's exit teardown, and run BitLengthOverflow in CI again
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Improvements
    • Successful CLI runs now perform available runtime cleanup before returning their exit status. This may help reduce leftover resources after a command completes.
    • Error handling remains unchanged: failures are reported and the command exits with a failure status.

The CLI invokes globalThis.gc when available after successful execution and before exiting with the run’s exit code. The jtreg passing-test list now includes BitLengthOverflow.java.

Changes: CLI exit and jtreg test eligibility

Layer / File(s) Summary
Successful CLI exit cleanup
src/node.ts
After runNode resolves, the CLI calls globalThis.gc when available, then exits with the returned code. The error path is unchanged.
Passing-test list update
test/jtreg/passing.txt
The passing-test list adds java/math/BigInteger/BitLengthOverflow.java.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Possibly related issues

  • Issue 42 is a release checklist that identifies this work as a release prerequisite.

Possibly related PRs

  • Project516/java-web#33: The launcher calls the main function whose successful-exit behavior changes here.
  • Project516/java-web#9: This PR exposes globalThis.gc, which the CLI now calls before a successful exit.
  • Project516/java-web#37: This PR reports a timeout in the same jtreg test that this change adds to the passing-test list.

Suggested reviewers: project516-review-bot

Merge Risk: Minimal · up to 1415a

The exit cleanup is reachable through the supported CLI path, and no actionable merge risk remains.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly describes the main change: collecting garbage before the java-web command exits to avoid a Node exit teardown hang.
Description check Passed The description explains the intermittent hang, the pre-exit garbage collection change, the restored test, validation results, and unchanged library behavior.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

LanguageTool

test/jtreg/passing.txt

LanguageTool could not check every text chunk; analysis is incomplete

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the closing run,
And calls the GC before it’s done.
One BigInteger test joins the queue,
The passing list now names it too.
Soft paws applaud the tidy end.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9f31cafa-defc-47a4-8b98-be30a044467c
Commits

Reviewing files that changed from the base of the PR and between 1a40f3e and 1415aa6.

Files ignored due to path filters: 1

  • test/jtreg/times.tsv is excluded by !**/*.tsv
Files selected for processing: 2

  • src/node.ts
  • test/jtreg/passing.txt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Context from checks skipped due to timeout: 10

  • GitHub Check: CodeRabbit
  • GitHub Check: jtreg / run (6)
  • GitHub Check: jtreg / run (2)
  • GitHub Check: jtreg / run (4)
  • GitHub Check: jtreg / run (7)
  • GitHub Check: jtreg / run (3)
  • GitHub Check: jtreg / run (1)
  • GitHub Check: jtreg / run (5)
  • GitHub Check: jtreg / run (8)
  • GitHub Check: test
Additional context used

Code guidelines: 1

AGENTS.md — auto-discovered
Path-based instructions: 1

Source excerpt: Compatibility first.

CodeRabbit inference engine (AGENTS.md)

Files:

  • test/jtreg/passing.txt
  • src/node.ts
Additional comments: 2

src/node.ts: 1

512-514: LGTM!

test/jtreg/passing.txt: 1

1429-1429: LGTM!

@project516-review-bot project516-review-bot 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.

The java-web command now forces garbage collection via globalThis.gc?.() immediately before process.exit, so node's exit teardown does not have to free large array buffers itself. This eliminates the hang observed in CI on x64 runners.


review-bot, model nvidia/nemotron-3.5-lightning:free, verdict approve

@Project516
Project516 enabled auto-merge (squash) November 5, 2026 01:26
@Project516
Project516 merged commit 0d72730 into master Nov 5, 2026
16 checks passed
@Project516
Project516 deleted the p516/exit-gc branch November 5, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant