A new flaw has been discovered in macOS High Sierra that can cause data to be lost when writing to disk images. It affects those formatted using the Apple File System (APFS) specifically, but it shouldn’t be a problem for your primary SSD.
Apple’s latest software releases have been plagued by pesky bugs. The company has worked quickly to fix the most significant issues, but many of the minor glitches still remain after macOS High Sierra and iOS 11 made their public debuts five months ago.
APFS bug can cause data loss
Now a new bug his been uncovered by Mike Bombich, software developer and creator of Carbon Copy Cloner for Mac. The flaw, which resides in APFS, can cause data loss when writing to “sparse bundle” disk images.
Sparse bundles, introduced with Mac OS X Leopard in 2007, are disk images that only occupy as much space as the data they contain. As you add more data, the size of the sparse bundle grows until it reaches the limit defined when it was created, or the underlying disk is full.
Sparse bundles are particularly useful for things like backup disks. Because they consist of “bands” of data, each stored in a separate file, it’s easier to keep them in sync with other volumes. And because they only use as much data as they need, they’re space efficient.
Bombich discovered the problem when macOS reported that one of his disk image volumes showed “ample free space,” despite the underlying disk being full. “Curious, I copied a video file to the disk image volume to see what would happen,” he writes.
“The whole file copied without error! I opened the file, verified that the video played back start to finish, checksummed the file – as far as I could tell, the file was intact and whole on the disk image. When I unmounted and remounted the disk image, however, the video was corrupted.”
Fortunately, this was just a test and the file that disappeared was just test data, Bombich adds. But other High Sierra users might not be so lucky. “If you’ve ever lost data, you know the kick-in-the-gut feeling that would have ensued.”
Apple knows about the problem
Bombich identified two problems — both of which have been tracked back to macOS’ “diskimages-helper” service.
One is that the free space on the APFS sparse bundle doesn’t update correctly when the free space on the host image is reduced. The other is that there is no error in macOS when requests to grow the sparse bundle fail and data ends up being written into a void.
Bombich has reported the problem to Apple, but it’s unclear if he received a response.
Until the flaw is patched, Carbon Copy Cloner is dropping support for disk images formatted with APFS. But it’s important to remember that this issue only affects sparse disk images; ordinary APFS volumes — like your Mac’s startup SSD — are safe.
Because this is the case, the flaw is “not likely to be a widespread problem,” Bombich explains.