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}
12if (getenv('SKIP_REPEAT')) {
13    /* The cwd is persistent across repeats */
14    die("skip Not repeatable");
15}
16?>
17--FILE--
18<?php
19
20$old_cwd = getcwd();
21
22mkdir(__DIR__ . "/foo");
23chdir(__DIR__ . "/foo");
24rmdir(__DIR__ . "/foo");
25
26// Outputs: / (incorrect)
27$new_cwd = getcwd();
28
29// Outputs: false (correct)
30$rp0 = realpath('');
31
32// Crash
33$rp1 = realpath('.');
34$rp2 = realpath('./');
35
36var_dump($old_cwd, $new_cwd, $rp0, $rp1, $rp2);
37?>
38--EXPECTF--
39string(%d) "%s"
40bool(false)
41bool(false)
42string(1) "."
43string(1) "."
44