Skip to content

libxposed modules scoped to android are never dispatched onSystemServerStarting; on HyperOS 2.0 (Android 15) android-scoped modules cause a system_server boot loop #1101

Closed as duplicate

Description

@McTr0

Environment

  • Device: Redmi Note 14 5G (beryl, MT6855), HyperOS OS2.0.211.0.VOQCNXM, Android 15 (SDK 35), kernel 5.10.236-android12-9
  • Root: KernelSU 3.3.1 (32680), LKM loaded post-boot
  • Zygisk Next 1.5.3 (880-22a1bf5-release)
  • Vector: v2.2 Debug (3080), manager v3.3.1
  • Module: io.github.varma322.gpssetter v0.4.1 (libxposed API 101), scoped to android / user 0 (System Framework)

What works

  • Vector framework injection into system_server succeeds on every cycle, including a fully clean hard-reboot + recovery cycle:
    module.cpp:394 postServerSpecialize: Attempting injection into system_server.
    ipc_bridge.cpp:363 RequestManagerBinderFromSystemServer: Manager binder from system_server: ...
    Injected Vector framework into system_server.
    
  • Per-app injection works: legacy modules load in app processes (VectorLegacyBridge Loading legacy module ...), libxposed in-process hooks in scoped apps work (verified end-to-end with a location hook in a scoped app).

What fails

  • Modules scoped to android are never dispatched onSystemServerStarting — across 4+ cycles, including clean ones.
  • The test module logs "GPS Setter: Hooking system server (SDK 35)" as the first statement of its onSystemServerStarting; this line appears zero times in main logcat, lspd verbose/modules/log.old logs — in any cycle.
  • The modules log shows only legacy-module loads in app processes; there is no system_server module entry at all, not even a failed attempt.
  • Functional consequence: provider-level location spoofing never starts (dumpsys location: gps/fused provider last location=null throughout), while per-app scoping works fine.

Verified not a configuration problem

  • modules_config.db: modules.enabled = 1 for the module; scope table contains (module, android, 0).
  • VectorConfigCache cache update / map swap observed right after the scope change.

Source-level findings (decompiled framework/vector.dex)

  • VectorLifecycleManager.dispatchSystemServerStarting exists and iterates activeModules, calling onSystemServerStarting per module — so the dispatcher itself is present.
  • Two silent no-log skip points in the chain that leads to it:
    1. HandleSystemServerProcessHooker.intercept: after chain.proceed(), it takes Thread.currentThread().getContextClassLoader(); if that is null, it silently does nothing (no log).
    2. StartBootstrapServicesHooker.intercept: dispatches only if (getSystemServerCL() != null) — a null classloader silently skips the whole dispatch (no log).
  • On this device the callback chain (ZygoteInit.handleSystemServerProcess → SystemServer.startBootstrapServices) never reaches the dispatch. Since both skip points are silent, the failure cannot be located from logs alone.

Repro

  1. Install any libxposed module that overrides onSystemServerStarting (e.g., a GPS Setter fork).
  2. Enable it in Vector and add System Framework (android) to its scope.
  3. Reboot (soft reboot via ksud or full reboot — both observed).
  4. Result: Injected Vector framework into system_server appears, but onSystemServerStarting is never dispatched; no system_server module entries in the modules log.

Suggestion

Add logging (or surface an error in the modules log) at the two silent-skip points, and/or check whether ZygoteInit.handleSystemServerProcess hooking or Thread.currentThread().getContextClassLoader() behaves differently on HyperOS 2.0 / Android 15, so that systemServerCL is never captured on this ROM.


Secondary, off-topic observation for context only: during ksud soft-reboot, zn-daemon sometimes aborts with FORTIFY: pthread_mutex_lock called on a destroyed mutex (SIGABRT) which can leave two generations of zn-daemon/zn-nsdaemon alive; that makes the re-injection timing worse but the failure above also reproduces on fully clean cycles.

Activity

  1. McTr0 commented on Nov 21, 2026

    @McTr0
    Author

    Follow-up: severity escalation — system_server boot loop on HyperOS 2.0 (Android 15)

    After filing the original report I built the module from current master (6f6b976, Vector-v2.2-40-Debug.zip, commit-count versionCode 40) and deployed it on the same device. The situation is more severe than "dispatch never happens": the device enters a system_server crash loop and cannot complete boot.

    Boot loop

    system_server dies every ~10 s with (from the crash buffer):

    java.lang.RuntimeException: Required services extension package is missing, config_servicesExtensionPackage had defined with android.ext.services, but can not find the package info on the system image, check if the package has a problem.
        at com.android.server.pm.PackageManagerService.getRequiredServicesExtensionPackageLPr(PackageManagerService.java:2763)
        at com.android.server.pm.PackageManagerService.<init>(PackageManagerService.java:2556)
        at com.android.server.pm.PackageManagerService.main(PackageManagerService.java:1803)
        at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:1389)
        at com.android.server.SystemServer.run(SystemServer.java:1035)
    
    • sys.boot_completed stayed 0 for 38+ minutes; the device was unusable until the recovery steps below.
    • dumpsys location gps/fused provider last location=null throughout — the original dispatch failure stands.

    New finding: /data/resource-cache tmpfs leak (global mount namespace)

    service.sh starts the daemon as unshare --propagation slave -m "$MODDIR/daemon" ..., and the daemon wrapper script mounts tmpfs -t tmpfs /data/resource-cache. On HyperOS 2.0, unshare (toybox) does not support --propagation:

    unshare: Unknown option 'propagation' (see "unshare --help")
    

    In some start paths the mount then lands in the global mount namespace. Observed on-device: mount shows tmpfs on /data/resource-cache on the global table, shadowing the real directory (RRO idmaps), surviving soft reboots and daemon restarts. umount /data/resource-cache + zygote restart was required to break the boot loop (after which the device boots with the module effectively inactive).

    Suggestion: fail hard (or retry) when namespace isolation cannot be established, instead of letting the mount escape into the global namespace.

    Other observations

    1. The previously installed release build (3080 / 88f8e1f) logged Failed to inject VectorService into system_server and then restarted system_server up to --system-server-max-retry=3 times. HEAD source ("leaving it running") already improves this — confirmed present at 6f6b976. Good change.
    2. framework/vector.dex is preloaded into a SharedMemory singleton held by the daemon for its lifetime: replacing framework/vector.dex on disk does nothing until the daemon is restarted. Worth documenting for people shipping debug framework dexes (I lost an hour to this).
    3. The original dispatch failure was re-verified on a fully clean hard-reboot + recovery cycle with an 8 MB logcat buffer: single system_server spawn, no crash, and still zero onSystemServerStarting dispatch. So the original report is not a race artifact.

    On-device recovery steps used (for reference)

    1. Kill vectord / zn-daemon / zn-nsdaemon-* (breaks injection) → zygote restart → boot completes with the module inactive.
    2. umount /data/resource-cache (removes the leaked tmpfs).
    3. ksud module disable zygisk_vector to prevent recurrence.

    Happy to test patches or CI builds on this device.

  2. changed the title [-]libxposed modules scoped to android are never dispatched onSystemServerStarting (framework injects into system_server but module loading never happens)[/-] [+]libxposed modules scoped to android are never dispatched onSystemServerStarting; on HyperOS 2.0 (Android 15) android-scoped modules cause a system_server boot loop[/+] on Nov 21, 2026
  3. JingMatrix commented on Nov 22, 2026

    @JingMatrix
    Owner
  4. McTr0 commented on Nov 22, 2026

    @McTr0
    Author

    Root-caused both symptoms, fixed in #1102. Summary of what the investigation on this device found:

    The boot loop was the daemon's /data/resource-cache shadow escaping its mount namespace. With the shadow in the global namespace, a booting system_server loses the idmap behind the com.google.android.overlay.modules.ext.services.cn overlay, reads the un-overlaid config_servicesExtensionPackage base value (android.ext.services, verified in framework-res; the only ExtServices on the image is com.google.android.ext.services in the APEX), and getRequiredServicesExtensionPackageLPr throws every cycle. This is the same mechanism the Samsung discussion #1042 describes; it triggered here because isolation is not reliable in the script's execution environment (toybox 0.8.11 unshare takes no --propagation, and plain unshare -m intermittently returns EPERM from the same root domain seconds apart). #1102 makes the start fail-safe: no private namespace → daemon starts unshadowed, never leaks, never refuses to start.

    The never-dispatched onSystemServerStarting was the scope storage, not the dispatch chain. config modules_config.db on this device stored the framework scope row as app_pkg_name='android' (the libxposed/CLI spelling, added via scope add ... android/0), while systemServerModuleRows() matched only 'system' (the manager's spelling) — so getModules() returned an empty list to system_server on every boot, cleanly, with nothing in any log. The classloader-capture chain the original report traced turned out to be healthy: an instrumented build showed handleSystemServerProcess's post-hook finding a valid context classloader (PathClassLoader[...services.jar]) and the hooks firing as designed. #1102 normalizes the spelling at the storage boundary and accepts both in the readers.

    After deploying a build from #1102 (scope row left as android, no other changes): first soft reboot boots cleanly with no PMS exception, the modules log gains the previously missing Loading module io.github.varma322.gpssetter ... successfully entry under uid 1000, and dumpsys location shows provider-level (gps + fused) spoofing working again — last location at the module's configured coordinates instead of null.

    Thanks for the discussion pointers and the fast CI turnaround on this repo; happy to rework anything in the PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions