Skip to content

Preserve run logs and harden startup lifecycle and failure handling - #167

Closed
Claude-Reverser wants to merge 2 commits into
diabl0w:masterfrom
Claude-Reverser:fix/bootstrap-module-errors
Closed

Claude-Reverser wants to merge 2 commits into
diabl0w:masterfrom
Claude-Reverser:fix/bootstrap-module-errors

Conversation

@Claude-Reverser

@Claude-Reverser Claude-Reverser commented Oct 20, 2026 •

Copy link
Copy Markdown

DFRoot currently ties live output to one screen instance, exposes boot results only through logcat, and can label an early startup marker or launcher exit as root success. This change preserves bounded current/previous diagnostics, adds log export without root, and keeps one active run owned through native completion and cleanup. Interrupted attempts and launcher completion are reported without claiming usable root.

Changes:

  • Add a process-wide coordinator and foreground service before native startup. Recreated screens reconnect to the same run; duplicate requests are rejected and settings cannot change during execution. Boot startup remains opt-in, attempts at most once per boot, and does not retry at unlock or restart interrupted work. The boot wake lock is capped at two minutes.
  • Keep app output and native bootstrap stages in private device-protected storage. Retain current/previous runs, cap Java output at 128 KiB and bootstrap output at 64 KiB per run, sync important checkpoints, and recover interrupted log rotation. Save logs exports a frozen text snapshot through Android’s file picker. Failure to prepare a separate log generation stops before native work; later logging failures preserve live output and do not abort cleanup.
  • Add tools/collect_logs.py for DFRoot-tag logcat and selected version/boot metadata, bounded watch capture with reconnection to the selected serial, and optional protected diagnostics using existing root access. It does not clear logs, change settings, start DFRoot, reboot, or upload files.
  • Preserve IPsec and child-process ownership through partial setup failures, reporter failures, and interrupted waits. Report preflight/bootstrap/cleanup outcomes explicitly; a launcher exit or an existing hook marker does not verify root.
  • Retain the original missing-module-directory fix and add checked native failure handling: bounded preference/environment reads, process-result validation, safe diagnostic-file access, module-disable errors, bounded optional soft-reboot polling, and ordered restoration with a distinct cleanup-failure status. An absent module directory means there are no modules to disable; real disable failures still stop before daemon launch.
  • Add host regression coverage and CI for the coordinator/log store, subprocess handling, bootstrap/filesystem paths, native failure paths, and fake-ADB collection. Document diagnostic and recovery limits.

Validation:

  • All five host suites passed on Ubuntu with JDK 21: bootstrap/filesystem tests, coordinator/log-store tests (129 assertions), process supervision (8 cases), native safety tests, and collector tests (17 cases). Relevant host suites also passed on macOS.
  • The final source passed :app:assembleDebug and :app:lintDebug with compile/target SDK 37, minimum SDK 32, and NDK 28.2.13676358. Lint reports 0 errors and 16 existing warnings. A targeted manifest suppression documents the existing broad package visibility required to discover compatible SU managers by native payload; discovery behavior is preserved.
  • APK signature, ZIP/16 KiB alignment, and both AArch64 executable entries passed verification. All eight unmodified KO payloads were verified byte-for-byte inside the APK against upstream build artifacts for base commit c274137e8c02b4f94f64d1b132d991b80c747340. No kernel-module source was changed or new kernel support claimed.

The expanded changes have not been installed on a device. Foreground-service behavior, boot startup, root acquisition, enabled-module recovery, and reset durability still need hardware validation. Notification-disabled Android may expose the service only in Task Manager, and an abrupt reset can still lose the buffered log tail.

The original report did not include filesystem errno, so its exact module-disable failure remains unknown. Recovery with Disable KSU Modules enabled on the affected phone remains untested. Root was previously verified using a separate experimental build with that option OFF; that does not validate this patch. This PR does not claim to resolve the separately observed kernel panic.

@Claude-Reverser Claude-Reverser changed the title Handle missing module directories and report disable failures Preserve run logs and harden startup lifecycle and failure handling Oct 20, 2026
@diabl0w

diabl0w commented Oct 20, 2026

Copy link
Copy Markdown
Owner

please rewrite this in your own words

@Claude-Reverser

Copy link
Copy Markdown
Author

My bad, I did not notice my agent did a PR.

Alright basically, my S23 Ultra was doing a kernel panic right after it said success and I couldnt get useful logs afterwards. This fixes the error when there’s no KSU modules folder, saves the logs and stops duplicate runs. I’ve now tested these changes in my Samsung-specific build after a full reboot, with “Disable KSU Modules” off, and root worked without another reboot. I still haven’t confirmed what caused the earlier kernel panics, so I can’t fully claim this fixes those yet.

@diabl0w

diabl0w commented Oct 21, 2026 via email

Copy link
Copy Markdown
Owner

@Claude-Reverser

Copy link
Copy Markdown
Author

It fixes the kernel panic when no modules are there.

@diabl0w

diabl0w commented Oct 21, 2026 via email

Copy link
Copy Markdown
Owner

@Claude-Reverser

Copy link
Copy Markdown
Author

Alright my bad i mixed up the custom build with this PR. My phone would kernel panic just from pressing "Launch Root" with all options off. The custom Samsung build now works without that crash, but those Samsung KernelSU changes arent included here. (I can make a separate PR for this fix)

The fix here is in disable_modules() in bootstrap.c. If /data/adb/modules doesn’t exist, it now continues because there’s nothing to disable, instead of stopping with an error. So calling this PR the kernel panic fix was my mistake.

@diabl0w

diabl0w commented Oct 21, 2026

Copy link
Copy Markdown
Owner

users enabling that option do so because they are having issues, so unexpected errors should prefer to abort rather than continue with root, which is what the code already does

@diabl0w diabl0w closed this Oct 21, 2026
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.

2 participants