1--TEST--
2Bug #77484 Zend engine crashes when calling realpath in invalid working dir
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die("skip can't remove CWD on Windows");
7}
8if (PHP_ZTS) {
9    /* TODO eliminate difference in TS build. */
10    die("skip Not for ZTS");
11}
12?>
13--FILE--
14<?php
15
16$old_cwd = getcwd();
17
18mkdir(__DIR__ . "/foo");
19chdir(__DIR__ . "/foo");
20rmdir(__DIR__ . "/foo");
21
22// Outputs: / (incorrect)
23$new_cwd = getcwd();
24
25// Outputs: false (correct)
26$rp0 = realpath('');
27
28// Crash
29$rp1 = realpath('.');
30$rp2 = realpath('./');
31
32var_dump($old_cwd, $new_cwd, $rp0, $rp1, $rp2);
33?>
34--EXPECTF--
35string(%d) "%s"
36bool(false)
37bool(false)
38string(1) "."
39string(1) "."
40