File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #78010: Segmentation fault during GC
3
+ --INI--
4
+ memory_limit=2G
5
+ --FILE--
6
+ <?php
7
+
8
+ class foo
9
+ {
10
+ public function __construct ()
11
+ {
12
+ $ this ->x = $ this ;
13
+
14
+ for ($ i = 0 ; $ i < 898 ; $ i ++) { //Will not trigger with <898
15
+ $ obj = [new stdClass , new stdClass ]; //This must have at least 2 elements
16
+ $ this ->y [] = $ obj ;
17
+ }
18
+ }
19
+ }
20
+
21
+ for ($ i = 0 ; $ i < 2 ; ++$ i ) { //This must run >=2 (increasing the number of elements in the array *2 will not do)
22
+ $ x = []; //This must be reset
23
+ foreach (array_fill (0 , 389 , 'x ' ) as &$ params ) { //Will not trigger <389
24
+ $ x [] = new foo ;
25
+ }
26
+ }
27
+
28
+ echo "Completed \n" ;
29
+
30
+ ?>
31
+ --EXPECT--
32
+ Completed
Original file line number Diff line number Diff line change 150
150
#define GC_DEFAULT_BUF_SIZE (16 * 1024)
151
151
#define GC_BUF_GROW_STEP (128 * 1024)
152
152
153
- #define GC_MAX_UNCOMPRESSED (1024 * 1024)
153
+ #define GC_MAX_UNCOMPRESSED (512 * 1024)
154
154
#define GC_MAX_BUF_SIZE 0x40000000
155
155
156
156
#define GC_THRESHOLD_DEFAULT 10000
@@ -314,7 +314,10 @@ static void gc_stack_free(gc_stack *stack)
314
314
315
315
static zend_always_inline uint32_t gc_compress (uint32_t idx )
316
316
{
317
- return idx % GC_MAX_UNCOMPRESSED ;
317
+ if (EXPECTED (idx < GC_MAX_UNCOMPRESSED )) {
318
+ return idx ;
319
+ }
320
+ return (idx % GC_MAX_UNCOMPRESSED ) | GC_MAX_UNCOMPRESSED ;
318
321
}
319
322
320
323
static zend_always_inline gc_root_buffer * gc_decompress (zend_refcounted * ref , uint32_t idx )
You can’t perform that action at this time.
0 commit comments