1--TEST-- 2Bug GH-9164: Segfault in zend_accel_class_hash_copy 3--EXTENSIONS-- 4opcache 5pcntl 6--INI-- 7opcache.enable=1 8opcache.enable_cli=1 9--FILE-- 10<?php 11 12$incfile = __DIR__.'/gh9164.inc'; 13 14// Generate enough classes so that the out of bound access will cause a crash 15// without relying on assertion 16$fd = fopen($incfile, 'w'); 17fwrite($fd, "<?php\n"); 18for ($i = 0; $i < 4096; $i++) { 19 fprintf($fd, "class FooBar%04d {}\n", $i); 20} 21fclose($fd); 22 23// Ensure cacheability 24touch($incfile, time() - 3600); 25 26$pid = pcntl_fork(); 27if ($pid == 0) { 28 // Child: Declare classes to allocate CE cache slots. 29 require $incfile; 30} else if ($pid > 0) { 31 pcntl_wait($status); 32 // Ensure that file has been cached. If not, this is testing nothing anymore. 33 if (!isset(opcache_get_status()['scripts'][$incfile])) { 34 print "File not cached\n"; 35 } 36 // Populates local cache 37 require $incfile; 38 var_dump(new FooBar4095); 39 unlink($incfile); 40} else { 41 echo "pcntl_fork() failed\n"; 42} 43 44?> 45--EXPECTF-- 46object(FooBar4095)#%d (0) { 47} 48