Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ PHP NEWS
- Opcache:
. Fixed bug GH-22857 (Function JIT emits wrong code for FETCH_OBJ_FUNC_ARG on a
property hook getter, losing register-held variables). (Zhao Hao)
. Fixed crash in observer API calling cases() on an enum preloaded with
opcache_compile_file(). (Thomas Atkinson)

- OpenSSL:
. Fix missing error check on invalid alpn protocols. (ndossche)
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@ static void zend_enum_register_func(zend_class_entry *ce, zend_known_string_id n
zif->module = EG(current_module);
zif->scope = ce;
zif->T = ZEND_OBSERVER_ENABLED;
if (CG(compiler_options) & ZEND_COMPILE_PRELOAD) {
zif->fn_flags |= ZEND_ACC_PRELOADED;
}
if (EG(active)) { // at run-time
if (CG(compiler_options) & ZEND_COMPILE_PRELOAD) {
zif->fn_flags |= ZEND_ACC_PRELOADED;
}
ZEND_MAP_PTR_INIT(zif->run_time_cache, zend_arena_calloc(&CG(arena), 1, zend_internal_run_time_cache_reserved_size()));
} else {
#ifdef ZTS
Expand Down
3 changes: 3 additions & 0 deletions ext/opcache/tests/preload_enum_compile_only.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

opcache_compile_file(__DIR__ . '/preload_enum.inc');
30 changes: 30 additions & 0 deletions ext/opcache/tests/preload_enum_observed_compile_only.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Crash in observer API calling cases() on a compile-only preloaded enum
--EXTENSIONS--
opcache
zend_test
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.preload={PWD}/preload_enum_compile_only.inc
zend_test.observer.enabled=1
zend_test.observer.observe_all=1
zend_test.observer.show_output=0
--SKIPIF--
<?php
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
?>
--FILE--
<?php

var_dump(MyEnum::cases());

?>
--EXPECT--
array(2) {
[0]=>
enum(MyEnum::Foo)
[1]=>
enum(MyEnum::Bar)
}
Loading