Hmbown/CodeWhale · error

Android loaded-image identity changed: /proc/self/maps has…

Error message

Android loaded-image identity changed: /proc/self/maps has device/inode {:x}:{:x}:{}, but update target {} is {:x}:{:x}:{}; refusing to replace it

What it means

After resolving the update target, the updater compares the device (major:minor) and inode recorded from the /proc/self/maps row against the stat() of the resolved file. If they differ, the file on disk is no longer the inode the process is executing from — the image was replaced or swapped underneath the running process — and the updater refuses to overwrite it, since the running binary could not be safely identified with the target path anymore.

Solutions

  1. Stop whatever is replacing the binary, reinstall the intended release, and re-run the update from the freshly started process.
  2. Verify identity manually: compare the device/inode from the error message against `stat` output for the target path.
  3. Ensure the path is not on overlayfs/bind mounts that alias inodes; run the update from the real underlying storage.
  4. Restart the device/app environment if a stale mapping is suspected, then retry once.
Defensive patterns

Strategy: validation

Validate before calling

use std::os::unix::fs::MetadataExt;
let md = std::fs::metadata(&target)?;
if md.ino() != expected_inode || md.dev() != expected_dev {
    eprintln!("target inode changed underneath the running process; refusing update");
    return Err(anyhow!("loaded-image identity changed"));
}

Try / catch

match run_update() {
    Err(e) if e.to_string().contains("identity changed") => {
        // restart the freshly installed binary by full path and retry
    }
    other => other?,
}

Prevention

When it happens

Trigger: validate_android_mapping_identity, called from android_loaded_executable_proof_report during android_loaded_executable_proof, when mapping.device_major/device_minor/inode do not equal the stat dev/ino of the canonicalized target path.

Common situations: Another process (installer, sync client, prior updater instance) replaced the binary via rename while this process ran; a bind mount or overlay made canonicalize() resolve to a different inode than the mapped one; filesystem corruption or container layer weirdness.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/cf8217554dabc24c. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/update.rs:519

#[cfg(any(target_os = "android", all(test, unix)))]
fn validate_android_mapping_identity(
    mapping: &AndroidImageMapping,
    candidate: &Path,
) -> Result<()> {
    use std::os::unix::fs::MetadataExt;

    let candidate_metadata = std::fs::metadata(candidate).with_context(|| {
        format!(
            "failed to stat Android update target {}",
            candidate.display()
        )
    })?;
    let (candidate_major, candidate_minor) = android_device_parts(candidate_metadata.dev());
    let identity_matches = mapping.device_major == candidate_major
        && mapping.device_minor == candidate_minor
        && mapping.inode == candidate_metadata.ino();
    if !identity_matches {
        bail!(
            "Android loaded-image identity changed: /proc/self/maps has device/inode {:x}:{:x}:{}, but update target {} is {:x}:{:x}:{}; refusing to replace it",
            mapping.device_major,
            mapping.device_minor,
            mapping.inode,
            candidate.display(),
            candidate_major,
            candidate_minor,
            candidate_metadata.ino()
        );
    }
    Ok(())
}

#[cfg(any(target_os = "android", all(test, unix)))]
fn android_device_parts(device: u64) -> (u32, u32) {
    // Linux/Bionic's dev_t encoding, matching makedev(3), major(3), and
    // minor(3). `/proc/self/maps` renders these components in hexadecimal.
    let major = ((device >> 8) & 0xfff) as u32;

View on GitHub (pinned to 73e0f67d83)