Mac randomly crashes, main boot volume disappears Retina Macbook from 2017 running Mojave here.
Every few days, my mac suddenly and randomly freezes (sometimes at times without user input) and crashes. When it tries to boot again, it fails and signals that it's missing a bootable partition. 

In this state, it fails however much I try. I then boot into Recovery Mode. Recovery Disk Utility can not detect the Macintosh HD (APFS with Filevault) boot volume anymore. I fiddle around with the OSX reinstall service (also can't detect it) as well as time machine, restart a few times, go into recovery again (without any difference) and sometimes, when I'm lucky, on reboot everything is fine again. Without repair or rescue.

Here is a photo from Single User Mode diskutil list at a time when it just happened, when the boot volume disappeared:



I don't know at all what this is about. Of course I never created these images by myself. 

When my Mac boots up again, everything is back to normal. The boot volume is back and those strange ones disappeared. Apple Diagnostics doesn't detect any hardware issue. However, when running fsck, I get the following error:

Checking the container superblock.
Checking the EFI jumpstart record.
Checking the space manager.
Checking the space manager free queue trees.
Checking the object map.
Checking volume.
Checking the APFS volume superblock.
The volume Macintosh HD was formatted by hfs_convert (748.1.46) and last modified by apfs_kext (945.200.129).
Checking the object map.
Checking the snapshot metadata tree.
Checking the snapshot metadata.
Checking snapshot 1 of 5.
error: dstream (id 2938340) does not have an associated dstream id object
warning: snapshot dstream corruptions are not repaired; they'll go away once the snapshot is deleted
error: dstream (id 3440445) does not have an associated dstream id object
error: invalid file extent (id 0x8603957554) logical address 135168 (expected 0)
Snapshot is invalid.
The volume /dev/rdisk1s1 could not be verified completely.


The problem didn't occur until some time ago. I now have a feeling that it's happening more and more often. And sometimes I'm not lucky and can't get access back for hours.
Any help would be greatly appreciated! Does this look like a hardware or software issue? Is it related to APFS? Is my Mac dying?
Would this be an issue Apple would take good care of when I send it in - and what happens if they can't even replicate it?

Thanks for any input.

Edit 1: I heard from several MacBook 12 users with the same problem. They said it was after all identified as a faulty logic board that had to be replaced.

Edit 2: The clean install didn’t help. I’ll send the device in for repair, praying that they find something.
To answer your question, is it hardware or software.

Suggested course of action would be

1- Back up you data

2- Do a "Clean Install"

That should eliminate an formatting issues your SSD had.

If problem occurs again, your SSD needs Replacement/Repair.