The debug warnings we've recorded in T400668 did not have anything interesting in them, so I decided to very carefully read the PHPSessionHandler::write() method, which emits these warnings, and look for holes in the logic.
I noticed that it does some === comparisons on arbitrary deserialized data, which wouldn't work as expected if that data could contain any PHP objects, and it turns out that it can. As a result, storing objects in session data causes unnecessary session writes (which probably explains at least some of the shutdown writes we've seen in T400249) and emits spurious warnings with $wgPHPSessionHandling = 'warn' (which hopefully explains all of the warnings we've seen in T400668).