See PHI1094. Previously, see D15785. Fixes T10853. Upstream: https://bugs.php.net/bug.php?id=77656.
PHP allows you to proc_open() into any CWD, including one that does not exist, is not readable, and/or is not executable.
We attempt to catch this, but don't do enough checks, and allow you to attempt execution into a directory which exists but which you can't read or execute.
Add more checks to prevent this. Also, try to make assertExists() more clever about cases where a path really doesn't exist versus cases where we aren't allowed to tell if a path exists or not because of a permissions issue.
(It's technically legal to chdir() into a directory you only have +x on, although this is probably ill-advised.)