mirror of
https://github.com/php/php-src.git
synced 2024-12-02 22:34:55 +08:00
Make weak ref notify robust against bailout
First drop it from EG(weakrefs), as the weakref_unref operation may call a destructor, which may bail out. Fixes oss-fuzz #39718.
This commit is contained in:
parent
d001682ac4
commit
a4b209fdcf
18
Zend/tests/weakrefs/weakmap_dtor_exception.phpt
Normal file
18
Zend/tests/weakrefs/weakmap_dtor_exception.phpt
Normal file
@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Exception during WeakMap destruction during shutdown
|
||||
--FILE--
|
||||
<?php
|
||||
$map = new WeakMap;
|
||||
$obj = new stdClass;
|
||||
$map[$obj] = new class {
|
||||
function __destruct() {
|
||||
throw new Exception("Test");
|
||||
}
|
||||
};
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught Exception: Test in %s:%d
|
||||
Stack trace:
|
||||
#0 [internal function]: class@anonymous->__destruct()
|
||||
#1 {main}
|
||||
thrown in %s on line %d
|
@ -157,8 +157,8 @@ void zend_weakrefs_notify(zend_object *object) {
|
||||
ZEND_ASSERT(tagged_ptr && "Tracking of the IS_OBJ_WEAKLY_REFERENCE flag should be precise");
|
||||
#endif
|
||||
if (tagged_ptr) {
|
||||
zend_weakref_unref(obj_addr, tagged_ptr);
|
||||
zend_hash_index_del(&EG(weakrefs), obj_addr);
|
||||
zend_weakref_unref(obj_addr, tagged_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user