Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions docs/ios27/SETTINGS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Settings on iOS 27.2.1 (24B156): the abort in MusicLibrary

Phone 1 moved from iOS 27.0.1 (24A446) to 27.2.1 (24B156) on 18 November 2026. That afternoon Settings (`Preferences`)
aborted with signal 6 in three boots, each time with the same ten frames: boot images c272m at 14:43 and 15:39 (camera test
arguments) and s0 at 15:48 (no camera arguments), about 9 to 40 seconds after Settings was opened. No boot on 24A446 (197
console logs) shows a Settings abort.

## The exception

The console's `CRASH Preferences` lines, symbolicated against 24B156's shared cache (names and logic only; the slide is the
`slide` of the `CRASH` line):

| frame | symbol |
|---|---|
| pc | `__pthread_kill` + 8 (libsystem_kernel) |
| 0 | `abort` + 148 (libsystem_c) |
| 1-2, 4 | libc++abi's terminate path (`__terminate`; x4 holds `"terminating due to %s exception of type %s"`) |
| 3 | `_objc_terminate` + 156 (libobjc) |
| 5-6 | `objc_exception_rethrow` + 44 (libobjc) |
| 7 | `-[ML3MusicLibrary databaseConnectionAllowingWrites:withBlock:]` + 160 (MusicLibrary) |
| 8 | `-[ML3MusicLibrary valueForDatabaseProperty:]` + 192 |
| 9 | `-[ML3MusicLibrary libraryUID]` + 60 |

x22 holds `CLNGC++\0`: an Objective-C exception, uncaught, rethrown by the `@finally` of
`databaseConnectionAllowingWrites:withBlock:` (which checks the connection back in and rethrows). The console keeps ten
frames only, so the Settings code that asks for `libraryUID` is not in the log.

What MusicLibrary raises there (24B156's MusicLibrary, read from its code): when a connection cannot be opened,
`-[ML3DatabaseConnection _raiseConnectionClosedException]` first calls `ML3DatabaseConnectionCheckDatabasePathAndRaiseIfNecessary`,
which checks, in order, the media container (`/var/mobile/Media`), the user-hash container, `iTunes_Control`
(`ML3DatabaseConnectionCheckPathiTunesControl`: it must exist, have attributes, not be owned by root and be owned by the caller's
user), `iTunes_Control/iTunes`, then the database file, and raises for the first that fails
(`ML3ExceptioniTunesControlDoesNotExist`: an `NSException` whose reason is built from `"%@ does not exist."` with the path).

`/private/var/mobile/Media/iTunes_Control` does not exist on the 24B156 root on phone 1 (root v9) nor on the last 24A446 root
(c30), both checked read-only. A restore makes it on an iPhone; this port never restores, so no iOS 27 root has had it.
`medialibraryd` is also not in the root's launchd jobs (`tools/ios27/speed/trim-s1.list`, one of the 86 speed trims).

The same ten frames are `atc`'s (AirTrafficControl) abort, 8 to 17 times a boot on 24A446 and on 24B156: the cause noted on
13-14 November in `UI-NIGHT-1114.md`, whose fix (`tools/ios27/ui/70-ui-stability.sh`) was never part of the full-root build.

Not yet captured on the phone: the exception's name and reason as printed (the console has no line for it in Preferences).
The order of MusicLibrary's checks and the root's contents make `iTunes_Control ... does not exist.` the one that fires; the
test boot below settles it.

Reproduced on the owner image (o272, no camera arguments, root v9) at 16:07 on 18 November: Settings opened and scrolled
without fault; **tapping General > About aborted it one second later** with the same ten frames. About lists the number of
songs and videos, which is where Settings asks MusicLibrary. Reopened, Settings ran on for over a minute. In the same boot,
atc aborted 14 times. On that boot Settings > Bluetooth drew its header and the Bluetooth switch (on), but no Devices section.

## What changed between 24A446 and 24B156

The root side did not change: the directory was missing and `medialibraryd` trimmed on both. The set of images that link
MusicLibrary is the same in both caches (`ipsw dyld imports`), and MusicLibrary's checks are the same. So the difference is in
when 24B156's Settings reaches `-[ML3MusicLibrary libraryUID]` (24A446's Settings evidently did not, in the panes used); which
pane or start-up path asks for it is not known (the backtrace is cut at ten frames). On 24B156 the abort came 9 to 40 seconds
after Settings opened, with or without taps in between, and once 7 seconds after a home swipe.

Ruled out: the camera work (the s0 boot had no camera arguments and the camera library is inserted only into cameracaptured and
Camera); a memory fault (signal 6 from `abort()`, `far` 0); MobileGestalt, IOKit, Bluetooth, Wi-Fi or a sandbox refusal (nothing
on the path asks for them; the raise is MusicLibrary's own path check).

## The change

`tools/ios27/fullroot/steps.d/45-media-library.sh` makes `iTunes_Control`, `iTunes_Control/iTunes` and `iTunes_Control/Music`,
mode 0755, owned by mobile (501), in every full-root build. It is on by default because it corrects a directory every iPhone
has; `ENABLE_MEDIA_LIBRARY_DIRS=0` turns it off, and `45-media-library.sh ROOT undo` takes the directories away when they are
empty. A writer connection (atc, for one) then creates the database itself (`-[ML3DatabaseConnection
_createDatabaseDirectoryIfNonexistent]`, `_createDatabaseFileIfNonexistent`). `check-root.sh` says whether the directory is
there. For a root already on the phone, the step can be run on its mounted image.

**Not run on a phone yet.** The test: the same root with the step, owner image o272, Settings opened, scrolled, **General >
About** (the tap that aborts it), Bluetooth, a home swipe and Settings again; expected 0 `CRASH Preferences` and 0 `CRASH atc`, and
`iTunes_Control/iTunes/MediaLibrary.sqlitedb` made by the phone. If Settings still aborts with the same frames, the next check
in the order above (the database file, which only `medialibraryd` or a writer makes) is the one to look at, and putting
`com.apple.medialibraryd` back (`edit-launchd.py --keep`) is the next test.

## Also seen on 24B156, separate

- About 30 to 70 app-extension aborts a boot (SettingsImportExtension, the Spotlight index extensions of Music, TV, Books,
Home, Tips, SupportFlow, Contacts): their frames are `objc_exception_throw` from PlugInKit's `checkEnvironment:` + 344, a
different exception from the one above (PlugInKit refuses the extension's environment after a failed system call). Not
investigated further; they do not take Settings down.
- Settings > Bluetooth opens as a blank white page on 24B156 (it drew on 24A446). No Settings abort came with it (boot o272,
13:35). Not investigated.
2 changes: 1 addition & 1 deletion docs/ios27/UI-NIGHT-1114.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Kernel: Scion-Project/xnu `s9/night-ui-ios27` (draft PR #23) on `s9/p1-everyday-
| ... and the time is lost at every boot | no clock iOS reads | `com.scion.lasttime` keeps the last known time on the data volume and puts the clock forward at start-up | `70-ui-stability.sh` |
| the root's time zone is US/Pacific | as installed | optional `SCION_TZ=Area/City` | `70-ui-stability.sh` |
| battery always 100 %, on AC | `SweetBattery` on STARLTE is a static fallback | the MAX77705 fuel gauge read only, on the bus the USB-switch code drives (shared under a lock) | `sweetfg=1` |
| atc aborts 12-17 times a boot with Wi-Fi up | MusicLibrary throws when `/var/mobile/Media/iTunes_Control` is missing | the directories, owned by mobile | `70-ui-stability.sh` |
| atc aborts 12-17 times a boot with Wi-Fi up | MusicLibrary throws when `/var/mobile/Media/iTunes_Control` is missing | the directories, owned by mobile | `70-ui-stability.sh`; since 18 Nov in every full-root build: `fullroot/steps.d/45-media-library.sh` (SETTINGS.md) |
| Books' and Podcasts' widgets die in dyld at every boot ("security policy does not allow @ path expansion") | the AMFI stand-in's dyld-policy answer lacks `AMFI_DYLD_OUTPUT_ALLOW_AT_PATH`; any app or extension with its own frameworks is refused | the bit set | `sweetatpath=1` |
| the wallpaper picker never makes a poster | PosterBoard's store: APFS purgeable `fsctl()`s fail on HFS (existing fix, `sweetspeed&0x1000000`, not in the everyday line), then CoreVideo aborts: MobileGestalt `HardwarePlatform` is NULL because the ADT root has no `platform-name` | `adt-platform-name.py` (t8030, the SoC of the model the S9 presents as) | ADT + `sweetspeed` bits |
| home screen: a black wedge top left | the stop-gap wallpaper is Apple's background layer, whose top rows are covered by the foreground layers in the real poster | the same layer cropped | root step |
Expand Down
3 changes: 3 additions & 0 deletions tools/ios27/fullroot/check-root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ for f in sbin/launchd System/Library/CoreServices/SpringBoard.app/SpringBoard us
System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e.01 \
private/var/keybags/systembag.kb System/Library/xpc/launchd.plist System/Library/xpc/launchd-disabled.plist; do
[[ -e $R/$f ]] && ok "present $f" || bad "missing $f"; done
# the media library's directory (steps.d/45-media-library.sh): without it MusicLibrary raises and Settings and atc abort (docs/ios27/SETTINGS.md)
M=$R/private/var/mobile/Media/iTunes_Control
if [[ -d $M && $(stat -f %u "$M") == 501 ]]; then ok "iTunes_Control owned by mobile"; else info "no iTunes_Control owned by mobile (Settings and atc abort in MusicLibrary; steps.d/45-media-library.sh)"; fi
# the wallpaper stand-in and the brightness library: the phone starts without them (docs/ios27/INSTALL-S9.md, section 4)
for f in usr/lib/m.dylib usr/lib/b.dylib; do [[ -e $R/$f ]] && ok "present $f" || info "absent $f (optional: wallpaper stand-in / brightness slider)"; done
# full-ness: nothing trimmed, symbols out
Expand Down
40 changes: 40 additions & 0 deletions tools/ios27/fullroot/steps.d/45-media-library.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# SPDX-License-Identifier: MIT-0
# 45-media-library.sh ROOT [undo] : the media library's directory, /private/var/mobile/Media/iTunes_Control with iTunes/ and Music/,
# owned by mobile (501), as a restore makes it on an iPhone. The IPSW's root does not have it and this port never restores, so it was
# missing on every iOS 27 root (24A446 and 24B156 alike).
#
# Why (iOS 27.2.1 24B156's MusicLibrary, its logic only; docs/ios27/SETTINGS.md): when a database connection cannot be opened,
# -[ML3DatabaseConnection _raiseConnectionClosedException] first runs ML3DatabaseConnectionCheckDatabasePathAndRaiseIfNecessary, which
# checks the media container, then iTunes_Control (ML3DatabaseConnectionCheckPathiTunesControl: it must exist, have attributes, not be
# owned by root and be owned by the caller's user), then iTunes_Control/iTunes, then the database file, and raises an Objective-C
# exception ("<path> does not exist.") for the first that fails. -[ML3MusicLibrary libraryUID] reads a database property through
# -[ML3MusicLibrary databaseConnectionAllowingWrites:withBlock:], which rethrows; nothing above catches it, so the process aborts.
# Settings (Preferences) aborts that way on 24B156 (phone 1, 18 Nov: three boots, the same ten frames each time), and atc aborts that
# way 8 to 17 times a boot on both builds. A writer connection creates iTunes_Control/iTunes and the database itself
# (-[ML3DatabaseConnection _createDatabaseDirectoryIfNonexistent] / _createDatabaseFileIfNonexistent) once iTunes_Control is there.
#
# Default ON: it is a correction (a directory every iPhone has), not new behaviour. ENABLE_MEDIA_LIBRARY_DIRS=0 turns it off.
# "undo" removes the directories only when they hold nothing (a database made on the phone is never deleted here).
# Idempotent. NOT RUN ON A PHONE yet.
set -euo pipefail
R=${1:?usage: 45-media-library.sh ROOT [undo]}
[[ ${ENABLE_MEDIA_LIBRARY_DIRS:-1} == 1 ]] || { echo "45-media-library: off (ENABLE_MEDIA_LIBRARY_DIRS=0)"; exit 0; }
MEDIA=$R/private/var/mobile/Media
M=$MEDIA/iTunes_Control
[[ -d $MEDIA ]] || { echo "45-media-library: $R has no /private/var/mobile/Media" >&2; exit 1; }
if [[ ${2:-} == undo ]]; then
rmdir "$M/iTunes" "$M/Music" "$M" 2>/dev/null || true
echo "45-media-library: iTunes_Control $([[ -e $M ]] && echo 'kept (not empty)' || echo removed)"
exit 0
fi
before=$([[ -d $M ]] && echo there || echo absent)
mkdir -p "$M/iTunes" "$M/Music"
chmod 0755 "$M" "$M/iTunes" "$M/Music"
# MusicLibrary refuses a directory owned by root, and one owned by another user than the reader (mobile, 501)
if [[ $EUID == 0 ]]; then
chown 501:501 "$M" "$M/iTunes" "$M/Music"
fi
owner=$(stat -f %u "$M" 2>/dev/null || stat -c %u "$M")
[[ $owner == 501 ]] || { echo "45-media-library: $M is owned by $owner, not mobile (501): run the build as root" >&2; exit 1; }
echo "45-media-library: iTunes_Control, iTunes_Control/iTunes, iTunes_Control/Music owned by mobile (was $before)"
Loading