Skip to content

iOS: every simulator copy names its seed in its stored paths, so a booted copy writes into the seed #1548

Closed

Description

@dpearson2699

What happened

On iOS, every simulator Simlock leases is a simctl clone of the kind's seed, and every copy keeps writing into that seed after it boots.

A simulator that has booted stores absolute paths to its own device folder and log folder: symbolic links, plists, JSON, SQLite rows. The seed boots once in the sources set (#makeSeed: create, boot, bootstatus, listapps, shutdown), so its stored paths name <simlock home>/devices/ios-sources/<seed udid>/… and ~/Library/Logs/CoreSimulator/<seed udid>. simctl clone copies those bytes, and provision changes only the LaunchServices database (#dropLaunchServicesDatabase) before the copy's first boot. So a booted copy's daemons follow the seed's paths and write into the seed.

Seen on one host, read without changing anything:

  • The seed of iPhone 18 Pro Max / iOS 27.0 was created at 16:28:18 and shut down at 16:28:52 (its device.plist is from then, state 1). Simlock never boots a seed again.
  • 18 files in the seed are newer than its device.plist, written at 16:30, 16:39, 17:29, 17:37 and later the same day: three files (about 3.8 MB in all) at each of six times, all under data/Library/Application Support/PRBPosterExtensionDataStore/…/com.apple.MercuryPoster/…/RuntimeSnapshot*-home.*. That is SpringBoard's home-screen poster snapshot, which a booting simulator writes into its own data folder, one set per lease boot.
  • The seed has 3 symbolic links whose targets name its own UDID, and 3 text files that contain it.
  • A baseline saved from a leased simulator names the seed too: its source's 3 link targets name the seed's UDID, not its own. So copies of that baseline also write into the seed.

The seed grows by one poster snapshot per lease, and every lease of the kind reads and writes some of the same state. Another tool that copied simulators the same way found, before it rewrote the paths, that its source grew by 11 GB of these snapshots and that its copies shared the source's Photos, Shortcuts and CloudKit state.

What you expected

A lease's simulator reads and writes only its own folders, and a seed (or a baseline's source) stays as it was made.

A possible fix: before a copy's first boot, rewrite the copy's stored paths to name its own folders. When the source and the copy live in the same parent folder, replacing the source's UDID with the copy's is enough and keeps every file's length; SQLite write-ahead logs need their frame checksums sealed again afterwards. Here the seed lives in the sources set and the copy in the device set, so the folders differ in more than the UDID. That needs either rewriting the whole folder path (lengths change, which breaks in-place edits of SQLite pages and binary plists), or making the seed in the folder copies live in.

How to reproduce

  1. drivers.ios.deviceSet: "default", start the daemon.
  2. simlock lease --platform ios --device "iPhone 17" --detach, wait for the grant, then simlock release <lease id>. Repeat a few times.
  3. Find the seed: sqlite3 -readonly <simlock home>/state.db "select udid, created_at from ios_source_data where kind = 'seed'".
  4. find <simlock home>/devices/ios-sources/<seed udid> -newer <simlock home>/devices/ios-sources/<seed udid>/device.plist -type f lists files written after the seed was shut down, one set of RuntimeSnapshot* files per lease.
  5. find <simlock home>/devices/ios-sources/<seed udid> -type l -exec readlink {} \; shows links that name the seed's own UDID.

It happens on every lease.

Environment

Logs and evidence

seed created      16:28:18
seed device.plist 16:28:52 (state 1)
files newer than device.plist: 18
  16:30:17  RuntimeSnapshot-<hash>-home.atx              3786024 bytes (+ 2 plists)
  16:39:53  RuntimeSnapshot-<hash>-home.atx              3786024 bytes (+ 2 plists)
  17:29:14  RuntimeSnapshot-<hash>-home.atx              3786024 bytes (+ 2 plists)
  17:37:27  RuntimeSnapshot-<hash>-home.atx              3786024 bytes (+ 2 plists)
  … two more sets
link targets in the seed naming its own UDID: 3
link targets in a saved baseline's source naming the seed's UDID: 3

Activity

  1. added
    bug:new
    on Nov 15, 2026
  2. self-assigned this
    on Nov 15, 2026
  3. V3RON commented on Nov 15, 2026

    @V3RON
    Contributor

    Reproduction

    Confirmed. A decision, not a fix: the code follows ADR 0061's Copy step, which is incomplete. Recommend a spec session and an ADR amending ADR 0061.

    src/drivers/ios/index.test.ts, "a provision leaves no link or file in the copy that names the seed's folders" (branch bug/1548-repro). The expected values are a proposal: every stored path in the copy names the copy's own folders.

    pnpm exec vitest run --project unit src/drivers/ios/index.test.ts -t "names the seed's folders"
    
    AssertionError: every stored path in the copy names the copy's own folders, none the seed's
    -   "logsLink": "/home/Library/Logs/CoreSimulator/…-000000000001",
    -   "toolsLink": "/Devices/…-000000000001/data/Library/Shortcuts/ToolKit/Tools-prod.sqlite",
    +   "logsLink": "/home/Library/Logs/CoreSimulator/…-0000000000aa",
    +   "toolsLink": "/Devices/sources/…-0000000000aa/data/Library/Shortcuts/ToolKit/Tools-prod.sqlite",
      (historyFile: the same, a JSON file naming the seed's folder)
    

    Read-only, one booted simulator on this Mac names its own UDID in:

    10 symbolic links (data/Library/Logs, Shortcuts/ToolKit/Tools-active, MobileAsset lockers)
    33 binary plists, 5 JSON, 2 XML, 3 SQLite + 5 WAL, 15 other binary files
    

    Root cause

    Decision. provision (src/drivers/ios/index.ts:935) runs simctl clone from the sources set into the device set. Before the first boot it changes only the LaunchServices database (index.ts:948), as the Copy row of ADR 0061 §2 says. saveSource (index.ts:859) does the same. ADR 0061 §1 keeps seeds in a separate set, so the seed's folder and the copy's folder differ by more than the UDID. A UDID swap cannot fix it. Any fix changes the Copy step.

    Simplest fix

    The ADR's Copy step gains one rule. Before the first boot of every clone, rewrite the source's device folder and log folder to the copy's in:

    • link targets
    • text files
    • binary plists (through plutil)
    • SQLite values (through SQL, never page edits)

    The Filesystem port needs readlink and symlink.

    Alternatives rejected

    • Make seeds in the copies' set and swap UDIDs only: under default the seed would show in Xcode's set (ADR 0061 §1, ADR 0048).
    • Boot the seed in the device set, then clone it into the sources set, so copies differ only by UDID: still needs the swap, and needs a device run to prove.
    • Make the seed read-only: copies that write their own state would fail.

    Risk

    • Binary files that are neither plists nor SQLite (15 here) may still hold the seed's path.
    • The rewrite adds time to every provision.
    • Only a slow-lane run can prove the seed stops changing.

    Fast track

    • Defect: no — decision: ADR 0061's Copy step
    • Fix tried: no — needs new port verbs and plist/SQLite rewriting
    • Nothing public added or broken: yes
    • No ADR or rule changed: no — amends ADR 0061 §1–2
    • One fix: no — rewrite or move seeds, both visible

    Written by an agent.

  4. removed their assignment
    on Nov 15, 2026
  5. V3RON commented on Nov 15, 2026

    @V3RON
    Contributor

    Being specified in #1561. This issue stays open until that feature ships.

    Written by an agent.

  6. github-actions commented on Nov 16, 2026

    @github-actions
    Contributor

    Shipped as #1561.

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

    bug:new

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions