Skip to content

fix: stop the native abort when the node stops with stuck work - #1999

Merged
ovitrif merged 1 commit into
masterfrom
chore/bump-ldk-node-rc81
Nov 23, 2026
Merged

ovitrif merged 1 commit into
masterfrom
chore/bump-ldk-node-rc81

Conversation

@ovitrif

@ovitrif ovitrif commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1536
Twin: synonymdev/bitkit-ios#1394

Updates ldk-node-android to 0.7.0-rc.81, which carries synonymdev/ldk-node#136 and synonymdev/ldk-node#138.

Description

  • Fixes the native SIGABRT A Tokio 1.x context was found, but it is being shutdown., the top crash on 3.1.1 (14 of 18 crash events on build 197).
    • When a stop times out, a background task (e.g. a VSS write that keeps retrying) can stay running. Releasing the node shut its Tokio runtime down under that task, and the task aborted the app as soon as it resumed.
    • ldk-node 0.7.0-rc.81 keeps the runtime alive until that work ends, then shuts it down. This covers foreground stops too, which fix: exit instead of releasing a detached node #1838 did not.
  • Updates the comments on the fix: exit instead of releasing a detached node #1838 background exit in LightningService.stop() and its test to describe why it stays, and widens the changelog fragment to every stop.
  • Adds the rc.81 checksums to gradle/verification-metadata.xml.

Out of Scope

Design

N/A — no UI changes.

Preview

N/A

QA Notes

Setup

Regtest build.

Journeys

N/A — no user-visible behaviour change.

Manual Tests

N/A

Automated Checks

Evidence

  • just compile, just test, just lint pass against the published com.synonym:ldk-node-android:0.7.0-rc.81.

Gaps

  • The stuck-stop path cannot be triggered on demand in the app; CI's E2E jobs cover the Lightning flows on this head.

Models used

  • Planning/scoping: Claude Opus 5.5 (reasoning: medium)
  • Implementation: Claude Opus 5.5 (reasoning: medium), Claude Sonnet 5.5 (reasoning: high)
  • Review: Claude Sonnet 5.5 (reasoning: high)

Bumps ldk-node-android to 0.7.0-rc.81 and updates the #1838 stop comments to match it.

Verified: just compile, just test, just lint against the published rc.81
@ovitrif ovitrif self-assigned this Nov 23, 2026
@ovitrif
ovitrif requested review from a team, coreyphillips and piotr-iohk and removed request for a team November 23, 2026 12:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T12:10:23.917038Z 3abadca PR opened
ℹ️ 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 Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

Updates ldk-node-android from 0.7.0-rc.80 to 0.7.0-rc.81 to consume the native shutdown fix.

  • The node runtime stays alive until stopped work finishes.

No actionable issues were found. Builds and native shutdown behavior were not independently run.

ovitrif explicitly acknowledged that foreground release can return while old work remains. The background exit is intentionally retained to prevent that work from overlapping a rebuilt node.

Reviews (1) · Last reviewed commit: "fix: stop the native abort when the node..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Regtest APK

Built from 3abadca (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

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

No findings. Bumps ldk-node-android to 0.7.0-rc.81, whose runtime now hands a runtime with undrained detached work to a reaper thread instead of shutting it down under that work, and rewrites the comments on the background exit in LightningService.stop() to match. Reviewed 3abadca, full tier (dependency manifest), static: on bitkit-android the PR's branch is not built here, so this is reasoned from the code, the ldk-node diff and CI.

What I checked, and 3 candidates I ruled out

Read in full: LightningService.stop(), exitBeforeRuntimeShutdown, releaseHandle, awaitNodeRelease, NodeRuntimeMonitor, the #1536 tests in LightningServiceTest.kt; ldk-node src/runtime.rs diff v0.7.0-rc.80..v0.7.0-rc.81 (synonymdev/ldk-node#136, synonymdev/ldk-node#138) and the block_in_place call sites in src/io/vss_store.rs.
Release: tag v0.7.0-rc.81 is 366d56e on ldk-node main; its only code change is src/runtime.rs, and the release notes say no API changes. The native-debug-symbols.zip checksum in verification-metadata.xml matches the release asset's digest; the .aar and .module hashes were accepted by Gradle verification in build-and-test.
Monitor still fires: rc.81 keeps the three Detaching ... error lines NodeRuntimeMonitor matches on (runtime.rs:412, :443, :484), so the background exit still triggers on the same signal.
CI: build-and-test green; lint, build-local and compose-ui / ui-tests still running at review time.

Ruled out

  • Foreground release now lets the old node's stuck VSS write land after a rebuilt node starts: the write completes inside the internal VSS runtime before the task touches the node runtime's timer, so it landed before the abort on rc.80 too. The overlap is not new; only the abort that followed it is gone.
  • Reaper keeps a runtime alive forever when the work never ends: bounded to one runtime per stuck stop, and it is ldk-node's deliberate trade-off in #138, not code in this diff.
  • Comment now overstates the fix: it says what rc.81 does (runtime kept until the work ends, destroy() returning after the 5 s drain) and why the background exit stays.

Merge confidence: 4/5, the stuck-stop path is tested only in ldk-node and the bump's on-device behaviour rests on CI's E2E jobs, which were still running.

Reviewer model: Claude Opus 5.5
Reasoning effort: Not exposed (the review run's metadata does not report it)

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

Two independent reviews, nothing blocking a merge.

worth doing, does not block

  • Release kdocs still claim no overlap with the old node, which rc.81 no longer gives (app/src/main/java/to/bitkit/services/LightningService.kt:596-623). After this bump, the kdocs on releaseHandle and awaitNodeRelease promise something the code no longer gives. They say the gate means a rebuild or storage wipe "never overlaps the old node's native lifetime" (LightningService.kt:604 and :620). In rc.81, Runtime::shutdown (ldk-node src/runtime.rs:100-112 at v0.7.0-rc.81) handles work still running after the 5 s drain differently. It passes the runtime to a reaper thread and returns, so free_node returns too. In the foreground, awaitNodeRelease then opens while the old node's detached work is still running and can still write. The comment this PR rewrote at :576-579 now says exactly that, so it contradicts the two kdocs just below it. exitBeforeRuntimeShutdown (:585) is also named for the old reason (runtime shutdown) rather than the new one (overlap). Suggest saying in the kdocs that the gate waits for free_node, not for detached work, so nobody relies on it for that. I confirmed this by reading the rc.81 runtime source against these kdocs.
  • QA notes say the stuck stop can't be triggered, but the issue has a recipe. The Gaps note says the stuck-stop path cannot be triggered on demand, so the only evidence is ldk-node's unit tests. The issue's 19 Oct comment disagrees: an iptables DROP on VSS (34.65.252.32:443) on a google_apis emulator produced the timed-out stop with Detaching background tasks after cancellation timed out. on every run. In the background that stop now ends in the #1838 process exit. rc.81's new path only runs on a foreground stop. One way to trigger it: 1. Block VSS. 2. Wait for a wallet sync to hang on its node_metrics write. 3. Restart the node from the foreground, e.g. restartWithElectrumServer by changing the Electrum server in Settings. Expected log order: 1. Detaching … 2. Deferring runtime shutdown until detached work still running at shutdown has ended. 3. After the network is restored: Shut down the runtime after detached work ended. There should be no abort. A run of this would be the first evidence in the app for the top crash on 3.1.1. I did not run it myself.

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

QA review

Scope: full PR diff against its merge base, at 3abadca9.

1 actionable finding — resolve or provide an evidence-backed rebuttal.

ldk-node-android 0.7.0-rc.81 is tag 366d56ef. Against v0.7.0-rc.80 the only library code change is src/runtime.rs: when detached work is still running, shutdown hands that runtime to a reaper and returns, instead of calling shutdown_background under it. The three Detaching … error lines NodeRuntimeMonitor matches are unchanged, so the background process exit still keys off the same signal. A foreground stop still calls destroy().

The releaseHandle and awaitNodeRelease kdocs still say free_node returns only after background tasks drain and that the gate keeps a rebuild or wipe from overlapping the old node's native lifetime. This shutdown returns while that work can still run.

Compared with bitkit-ios#1394 at 45ff9d4, which pins the same 0.7.0-rc.81 revision. iOS drops the node after stop() and has no process exit. Android still exits the process when that detach log was seen and the app is in the background. Only this shutdown contract was compared.

Device testing: not performed in this review. The checks on 3abadca9 show build-and-test, lint, detekt, compose-ui / ui-tests, and the local e2e shards succeeded. This review inspected those results. They do not assert the stuck-stop path. LightningServiceTest still covers the background-exit decision. The native deferral is in the ldk-node runtime.rs tests, which were read and not executed here. Gradle verification for the rc.81 AAR, module, and native debug symbols is present in the same shape as rc.80, and build-and-test accepted the checksums it resolved.

Suggested additional test cases

Android regtest on a rooted API 35 emulator, fresh wallet, node running. Block TCP 443 to bitkit.stag0.blocktank.to (the non-mainnet VSS URL in Env) and leave Electrum reachable. Keep the app in the foreground for the whole stop: the background path calls exitProcess before destroy(). Change the Electrum server so restartWithElectrumServer stops and rebuilds the node. Expected logs: Detaching background tasks after cancellation timed out., then Deferring runtime shutdown until detached work still running at shutdown has ended., and no SIGABRT. After unblocking VSS: Shut down the runtime after detached work ended. This adapts the stop recipe in issue 1536.

Findings

  • [LOW] State that the release gate does not wait for detached work — inline at app/src/main/java/to/bitkit/services/LightningService.kt:577.

Reviewer model: grok-4.7
Reasoning effort: xhigh

@ovitrif

ovitrif commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Merging: approved by @coreyphillips and @piotr-iohk on this head, required checks green, @piotr-iohk's kdoc point tracked in #2003.

@ovitrif
ovitrif merged commit d8ed1b4 into master Nov 23, 2026
24 checks passed
@ovitrif
ovitrif deleted the chore/bump-ldk-node-rc81 branch November 23, 2026 13:51
@ovitrif

ovitrif commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Release kdocs still claim no overlap with the old node, which rc.81 no longer gives

QA notes say the stuck stop can't be triggered, but the issue has a recipe.

@coreyphillips The kdocs are tracked in #2003 and get fixed in the next ldk-node bump PR, along with the exitBeforeRuntimeShutdown name. That PR also takes this path, so I'll run your iptables recipe there and post the log order as its evidence.

@ovitrif

ovitrif commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

One way to trigger it: 1. Block VSS. 2. Wait for a wallet sync to hang on its node_metrics write. 3. Restart the node from the foreground

@coreyphillips Ran it on rc.82 in #2004: the log order matched (Detaching …, Deferring runtime shutdown …, then Shut down the runtime after detached work ended. once VSS was back), with no abort; the full order is in its Evidence.

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.

crash: native abort when the node restarts after returning from the background

4 participants