Repository navigation
Conversation
boot_stage_handler sets LateStartDone after running late_start() but never checks it, so every LATE_START request runs all service.d and module service.sh scripts again. LATE_START can arrive more than once per boot: the injected rc binds magisk --service to two init events (`on nonencrypted` and `on property:vold.decrypt=trigger_restart_framework`), and an event may also fire more than once. On a Pixel 5 (Android 11, FBE) the daemon receives two LATE_START requests ~70ms apart on every boot, so every service script runs twice. Modules that start a long-running daemon from service.sh without their own single-instance guard (e.g. Tricky Store) end up with two daemon instances. Check LateStartDone before running late_start(), the same way PostFsDataDone already guards POST_FS_DATA. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Running |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Only run late_start service scripts once
Problem
boot_stage_handlerserializes boot stages and setsBootState::LateStartDoneafter runninglate_start(), but never checks that flag. EveryLATE_STARTrequest runs allservice.dscripts and moduleservice.shscripts again.LATE_STARTcan reach the daemon more than once per boot. The injected rc (native/src/init/rootdir.rs) bindsmagisk --serviceto two init events, and an event may also fire more than once:I haven't determined which event fires twice on the device below (it uses FBE and
vold.decryptis empty after boot, so a repeatednonencryptedseems more likely), but the handler shouldn't rely on a single request either way.Observed
Pixel 5 (redfin), Android 11 (RQ3A.211001.001), file-based encryption, Magisk 31.0. Every boot,
magisk.logshows two late_start passes from different daemon threads ~70ms apart:The same pattern is present in the previous boot's log (
magisk.log.bak). Modules that start a long-running daemon fromservice.shwithout their own single-instance guard end up with duplicate daemons; here Tricky Store ran two instances (~100 MB RAM) on every boot.Fix
Check
LateStartDonebefore runninglate_start(), the same wayPostFsDataDonealready guardsPOST_FS_DATA.LateStartDoneis only set afterlate_start()has actually run, so an earlyLATE_STARTthat is skipped (e.g. before post-fs-data completed) does not block a later one.Testing
libmagisk.sodiffers, by a single immediate in theLATE_STARTbranch (state mask0b1001->0b1011).magisk.logshows a singlelate_start service mode running, one instance of every service script, a single Tricky Store daemon, root and Zygisk modules working normally../build.py clippypasses.🤖 Generated with Claude Code