File tree Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Original file line number Diff line number Diff line change 5
5
- Core:
6
6
. Fixed GH-13569 (GC buffer unnecessarily grows up to GC_MAX_BUF_SIZE when
7
7
scanning WeakMaps). (Arnaud)
8
+ . Fixed bug GH-13612 (Corrupted memory in destructor with weak references).
9
+ (nielsdos)
8
10
9
11
- Gettext:
10
12
. Fixed sigabrt raised with dcgettext/dcngettext calls with gettext 0.22.5
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-13612 (Corrupted memory in destructor with weak references)
3
+ --FILE--
4
+ <?php
5
+
6
+ class WeakAnalysingMapRepro
7
+ {
8
+ public array $ destroyed = [];
9
+ public array $ ownerDestructorHandlers = [];
10
+
11
+ public function __construct ()
12
+ {
13
+ $ handler = new class ($ this ) {
14
+ private \WeakReference $ weakAnalysingMap ;
15
+
16
+ public function __construct (WeakAnalysingMapRepro $ analysingMap )
17
+ {
18
+ $ this ->weakAnalysingMap = \WeakReference::create ($ analysingMap );
19
+ }
20
+
21
+ public function __destruct ()
22
+ {
23
+ var_dump ($ this ->weakAnalysingMap ->get ());
24
+ }
25
+ };
26
+
27
+ $ this ->destroyed [] = 1 ;
28
+ $ this ->ownerDestructorHandlers [] = $ handler ;
29
+ }
30
+ }
31
+
32
+ new WeakAnalysingMapRepro ();
33
+
34
+ echo "Done \n" ;
35
+
36
+ ?>
37
+ --EXPECT--
38
+ NULL
39
+ Done
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ ZEND_API void zend_object_std_dtor(zend_object *object)
50
50
{
51
51
zval * p , * end ;
52
52
53
+ if (UNEXPECTED (GC_FLAGS (object ) & IS_OBJ_WEAKLY_REFERENCED )) {
54
+ zend_weakrefs_notify (object );
55
+ }
56
+
53
57
if (object -> properties ) {
54
58
if (EXPECTED (!(GC_FLAGS (object -> properties ) & IS_ARRAY_IMMUTABLE ))) {
55
59
if (EXPECTED (GC_DELREF (object -> properties ) == 0 )
@@ -88,10 +92,6 @@ ZEND_API void zend_object_std_dtor(zend_object *object)
88
92
FREE_HASHTABLE (guards );
89
93
}
90
94
}
91
-
92
- if (UNEXPECTED (GC_FLAGS (object ) & IS_OBJ_WEAKLY_REFERENCED )) {
93
- zend_weakrefs_notify (object );
94
- }
95
95
}
96
96
97
97
ZEND_API void zend_objects_destroy_object (zend_object * object )
You can’t perform that action at this time.
0 commit comments