2 iPhone restores later, it's clear: iTunes + iOS no longer viable for music
It's well-known that copying music from iTunes to an iOS device has become unreliable. Beware, because failures can cause so much damage that the Music app will no longer launch, that all in-use storage will be marked as "Other", and that certain Settings pages will no longer open. After my second full iPhone restore, I won't risk storing music on my iPhone ever again.
To others who have experienced sync failures: have you or Apple ever found a root cause? I have found one: a bad memory reference by the iOS Media Library Daemon. (For non-technical readers, a "daemon" is a program that runs all the time, accomplishing something useful behind-the-scenes.)
Background
Systems: iPhone 7 Plus 256 GB, latest iOS; Mac mini 2014, latest MacOS and iTunes; original Apple USB-to-Lightning cable, plugged directly into the Mac mini
Configuration: Manually manage music; 50 GB of Apple Lossless and AAC 320 tracks, imported from CDs using iTunes
What Happened
While copying music from my iTunes library to my iPhone, watching progress both at the top of the iTunes window on my Mac and in Music > Downloads on my iPhone, I noticed that the Music app had crashed. The sync spinner near the top left of the iPhone screen continued to turn, iTunes continued to report that files were being copied, but the Music app would not restart, and the song count in Settings > General > About would get stuck "Loading...". After iTunes had glibly gone through the list of files, it got stuck "Waiting for items to copy" (over 2 hours!). I finally canceled the sync in iTunes, then ejected the iPhone and power-cycled it.
Now, when I launch the Music app, it crashes and immediately returns to the home screen. Ditto for Settings > General > About (those pesky song counts and storage statistics!), Settings > General > iPhone Storage, and Settings > Music. iTunes sees the iPhone, but reports all in-use storage as "Other". Clicking "Back Up Now", does nothing, and "Sync" is greyed out. Toggling a setting such as "Sync with this iPhone over Wi-Fi" and clicking "Apply" also does nothing.
What I Tried
I restored from a backup, via iTunes. The iPhone came back, but with the same problems. I used Restore Mode with the so-called software update option (not an really an update, because the phone already had the latest iOS release) to reset the phone to factory condition. This is the option that requires the 3 GB download, and overwrites the phone's firmware and operating system software. Only then did apply my backup. Copying music failed again at a random point.
Apple Support might have insights, I thought. Before contacting them, I took a look at the spyware/"phone home" facility that Apple builds in to its systems. I AirDropped reports from Settings > Privacy > Analytics > Analytics Data from the iPhone to my Mac mini. Crash reports labeled "medialibraryd", "JetsamEvent", "Music", and "Preferences" had timestamps that corresponded either to the moment when the sync aborted, or to subsequent attempts to open the Music app or the Settings pages. And there was the smoking gun: a bad memory reference by the iOS Media Library Daemon!
I'm a computer scientist with 20 years' experience; bad memory references are a typical bug, indicative of low-quality software. (There's also a possibility that bad RAM or bad flash memory in my iPhone led to such a result.) Apply Support lacked sufficient expertise to help. "Mark" asked me if I'd tried restoring/resetting the phone. "Kimberly", a higher-level associate, had nothing to add. I wasted 27 minutes in chat, and while they were consulting their references, I looked up the cost of an out-of-warranty iPhone repair at a US Apple Store. Why would I spend $349 and 5 business days, to have a technician take a look just in case the RAM or the flash memory is bad?
This was my final Apple purchase. When I replace this phone, it will be with two devices: one to serve as a cell phone, the other to serve as a portable music player.
Crash report from Settings > Privacy > Analytics > Analytics Data
medialibraryd-2017-10-15-162751.ips:
{"app_name":"medialibraryd","app_version":"","bug_type":"109","timestamp":"2017- 10-15 16:27:51.53 -0700","os_version":"iPhone OS 11.0.3 (15A432)","incident_id":"B8B45886-81C3-4AD4-9C8E-1CCC3E51A9E1","slice_uuid":"e7 6c0993-f3d5-3b91-b250-c8ab7e71b178","build_version":"","is_first_party":true,"sh are_with_app_devs":false,"name":"medialibraryd"}
Incident Identifier: B8B45886-81C3-4AD4-9C8E-1CCC3E51A9E1
CrashReporter Key: b6af6c5675aa9fdf9dfff493516608075cba5338
Hardware Model: iPhone9,2
Process: medialibraryd [120]
Path: /System/Library/PrivateFrameworks/MusicLibrary.framework/Support/medialibraryd
Identifier: medialibraryd
Version: ???
Code Type: ARM-64 (Native)
Role: Unspecified
Parent Process: launchd [1]
Coalition: com.apple.medialibraryd [197]
Date/Time: 2017-10-15 16:27:51.4769 -0700
Launch Time: 2017-10-15 11:56:13.9735 -0700
OS Version: iPhone OS 11.0.3 (15A432)
Baseband Version: 3.00.00
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0002000100fb0cf0
VM Region Info: 0x2000100fb0cf0 is not in any region. Bytes after previous region: 562946211777777
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
MALLOC_NANO (reserved) 00000001d8000000-00000001e0000000 [128.0M] rw-/rwx SM=NUL ...(unallocated)
--->
UNUSED SPACE AT END
...
iPhone 7 Plus, iOS 11.0.3, 256 MB