I have observed this problem when certain Thunderbolt arrays are plugged in, I begin a normal MacOS normal shutdown, then it reboots. Upon reboot it displays a kernel panic error log which sometimes refers to a shutdown I/O stall or (more recently) “Halt/Restart Timed Out @IOPlatformExpert.cpp:883”.
Unlike user-mode code where exceptions can crash that app, the involved code here is kernel mode, so it will crash the entire OS. Of course it’s in the process of shutting down anyway, but it might cause an ungraceful shutdown — I don’t know where in the overall shutdown sequence it happens.
Fortunately this source code is open source and examination of it indicates that within IOPlatformExpert.cpp it was attempting to get the machine name from the device tree using the key value gIODTModelKey. For some reason that returned a NULL value, it dereferenced that variable which caused a crash. I don’t know the underlying cause; maybe it’s interrogating all I/O devices as part of sending dismount or shutdown commands and some Thunderbolt I/O devices do not respond within the expected period. It would seem a bug in the MacOS code because IMO it should continue the MacOS shutdown and log an error, not crash.
I have several RAID arrays and it only happens on one of them, an OWC Thunderbay 4 Mini which contains 4 x 4TB Samsung EVO 870 SATA III SSDs. It is using regular AppleRAID not SoftRAID.
This is on an M1 Ultra Mac Studio running MacOS Monterey 12.6.2, but it also happened on my iMac Pro on several prior versions of MacOS. My workaround is manually dismount and unplug that Thunderbolt array before I shut down or reboot the machine.