Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #80092: ZTS + preload = segfault on shutdown
After preloading has executed, the executor globals for class_table and function_table are still referring to the values during preloading. If no request happens after that then these values will remain dangling pointers. If then the -v option on CLI or -h option (and possibly others) on CGI is provided, there is a double free. Fix it by nulling the pointers explicitly after preloading has finished to fix it for all SAPIs. Closes GH-12311.
- Loading branch information
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--TEST-- | ||
Bug #80092 (ZTS + preload = segfault on shutdown) | ||
--SKIPIF-- | ||
<?php | ||
include 'skipif.inc'; | ||
if (substr(PHP_OS, 0, 3) == 'WIN') { | ||
die ("skip not for Windows"); | ||
} | ||
$extDir = ini_get('extension_dir'); | ||
if (!file_exists($extDir . '/opcache.so')) { | ||
die ('skip opcache shared object not found in extension_dir'); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
$cmd = [ | ||
PHP_BINARY, '-n', | ||
'-dextension_dir=' . ini_get('extension_dir'), | ||
'-dzend_extension=opcache.so', | ||
'-dopcache.enable=1', | ||
'-dopcache.enable_cli=1', | ||
'-dopcache.preload=' . __DIR__ . '/preload.inc', | ||
'-v' | ||
]; | ||
|
||
$proc = proc_open($cmd, [['null'], ['pipe', 'w'], ['redirect', 1]], $pipes); | ||
echo stream_get_contents($pipes[1]); | ||
|
||
?> | ||
--EXPECTF-- | ||
preloaded | ||
PHP %s | ||
Copyright (c) The PHP Group | ||
Zend Engine %s | ||
with Zend OPcache %s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class SomeClass {} | ||
|
||
function foo() {} | ||
|
||
echo "preloaded\n"; |