File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug object gc not working in shutdown
3
+ --FILE--
4
+ <?php
5
+ ini_set ('memory_limit ' , '2M ' );
6
+ register_shutdown_function (function () {
7
+ for ($ n = 1000 * 1000 ; $ n --;) {
8
+ new stdClass ;
9
+ }
10
+ echo "OK \n" ;
11
+ });
12
+ ?>
13
+ --EXPECT--
14
+ OK
Original file line number Diff line number Diff line change @@ -234,8 +234,9 @@ struct _zend_executor_globals {
234
234
void * reserved [ZEND_MAX_RESERVED_RESOURCES ];
235
235
};
236
236
237
- #define EG_FLAGS_INITIAL 0x00
238
- #define EG_FLAGS_IN_SHUTDOWN 0x01
237
+ #define EG_FLAGS_INITIAL (0)
238
+ #define EG_FLAGS_IN_SHUTDOWN (1<<0)
239
+ #define EG_FLAGS_OBJECT_STORE_NO_REUSE (1<<1)
239
240
240
241
struct _zend_ini_scanner_globals {
241
242
zend_file_handle * yy_in ;
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_destroy(zend_objects_store *objec
41
41
42
42
ZEND_API void ZEND_FASTCALL zend_objects_store_call_destructors (zend_objects_store * objects )
43
43
{
44
+ EG (flags ) |= EG_FLAGS_OBJECT_STORE_NO_REUSE ;
44
45
if (objects -> top > 1 ) {
45
46
uint32_t i ;
46
47
for (i = 1 ; i < objects -> top ; i ++ ) {
@@ -140,10 +141,10 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_put(zend_object *object)
140
141
{
141
142
int handle ;
142
143
143
- /* When in shutdown sequesnce - do not reuse previously freed handles, to make sure
144
+ /* When in shutdown sequence - do not reuse previously freed handles, to make sure
144
145
* the dtors for newly created objects are called in zend_objects_store_call_destructors() loop
145
146
*/
146
- if (EG (objects_store ).free_list_head != -1 && EXPECTED (!(EG (flags ) & EG_FLAGS_IN_SHUTDOWN ))) {
147
+ if (EG (objects_store ).free_list_head != -1 && EXPECTED (!(EG (flags ) & EG_FLAGS_OBJECT_STORE_NO_REUSE ))) {
147
148
handle = EG (objects_store ).free_list_head ;
148
149
EG (objects_store ).free_list_head = GET_OBJ_BUCKET_NUMBER (EG (objects_store ).object_buckets [handle ]);
149
150
} else if (UNEXPECTED (EG (objects_store ).top == EG (objects_store ).size )) {
You can’t perform that action at this time.
0 commit comments