Commit Graph

210 Commits

Author SHA1 Message Date
George Peter Banyard
c40231afbf
Mark various functions with void arguments.
This fixes a bunch of [-Wstrict-prototypes] warning,
because in C func() and func(void) have different semantics.
2021-05-12 14:55:53 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Dmitry Stogov
9fc11762e5 PHP array cannot refer to EG(symbol_table) any more. Replace corresponding checks by ZEND_ASSERT(). 2021-01-11 18:26:01 +03:00
Nikita Popov
0fb2374e06 Make GC default threshold handling consistent
While the initial threshold is set to 10001 roots, the threshold
adjustment logic may then set it to 10000. The exact value really
doesn't matter, but we should make it consistent.
2020-10-23 10:30:07 +02:00
Dmitry Stogov
bb3d4456ee Change GC_COLLECTABLE flag into GC_NOT_COLLECTABLE to simplify GC_MAY_LEAK() check 2020-06-15 14:26:22 +03:00
Nikita Popov
50c87e92fc Use GC stack in nested data removal
We should be doing this anyway to prevent stack overflow, but on
master this is important for an additional reason: The temporary
GC buffer provided for get_gc handlers may get reused if the scan
is performed recursively instead of indirected via the GC stack.

This fixes oss-fuzz #23350.
2020-06-12 15:02:12 +02:00
Nikita Popov
4a7ec516e0 Move label to correct position 2020-06-12 10:44:37 +02:00
Nikita Popov
0949214ab3 Fix null pointer UB in GC
This is just plain stupid: In C, it is not permitted to add zero
to a null pointer. In C++, it is permitted.
2020-06-12 10:33:39 +02:00
twosee
1b85e749c7 Fix warning of strict-prototypes
Closes GH-5673.
2020-06-07 10:36:50 +02:00
Nikita Popov
48a34bc120 Add helper APIs for get_gc implementations
get_gc() implementations that need to explore heterogeneous data
currently work by computing how many GC entries they need,
allocating a buffer for that and storing it on the object. This
is inefficient and wastes memory, because the buffer is retained
after the GC run.

This commit adds an API for a single global GC buffer, which can
be reused by get_gc implementations (as only one get_gc call is
ever active at the same time). The GC buffer will automatically
grow during the GC run and be discarded at the end.
2020-04-27 10:48:22 +02:00
Tyson Andre
500ba8b2b8 Handle reallocated root buffer during GC destroy phase (v2)
We no longer protect GC during the destroy phase, so we need to
deal with buffer reallocation.

Note that the implementation of spl_SplObjectStorage_free_storage
will call the destructor of SplObjectStorage, and free the instance properties,
which I think is what caused the root buffer to be reallocated.
(`current` is a pointer for an index within the root buffer?)

This fixes bug #78811 for me.

Closes GH-4935
2019-11-23 10:24:48 -05:00
Nikita Popov
9899fdc454 Merge branch 'PHP-7.4'
* PHP-7.4:
  Handle reallocated root buffer during GC destroy phase
  Zend Engine version is no longer in -dev
2019-11-15 15:54:46 +01:00
Nikita Popov
3f4a15113c Handle reallocated root buffer during GC destroy phase
We no longer protect GC during the destroy phase, so we need to
deal with buffer reallocation.

Possible fix for bug #78811.
2019-11-15 15:53:49 +01:00
Nikita Popov
3b52307c86 Merge branch 'PHP-7.4' 2019-09-24 12:19:14 +02:00
Nikita Popov
73115ef873 Fixed bug #78589
Don't protect GC while destroying zvals. We may need to add GC
roots during this phase.
2019-09-24 12:17:21 +02:00
Nikita Popov
38c2230d07 Merge branch 'PHP-7.4' 2019-08-26 17:54:00 +02:00
Nikita Popov
fa8565a0f1 Merge branch 'PHP-7.3' into PHP-7.4 2019-08-26 17:52:56 +02:00
Nikita Popov
461db52400 Merge branch 'PHP-7.2' into PHP-7.3 2019-08-26 17:52:37 +02:00
Nikita Popov
589542f50c Remove properties HT from nested GC data
The properties HT may be a GC root itself, so we need to remove it.
I'm not sure this issue actually applies to PHP 7.2, but committing
it there to be safe. As seen from the test case, the handling here
is rather buggy on 7.2.
2019-08-26 17:49:37 +02:00
Nikita Popov
ded28e2435 Merge branch 'PHP-7.4' 2019-08-14 17:53:38 +02:00
Nikita Popov
c238b5bbef Fix reference printing in GC tracing 2019-08-14 17:51:41 +02:00
Nikita Popov
8c927442b4 Merge branch 'PHP-7.4' 2019-08-13 14:54:57 +02:00
Nikita Popov
60a7e60b61 Fixed bug #72530
For objects with destructors, we will now only call the destructor
in the initial GC run, and remove any nested data. The object is
marked purple so it will be considered a root for the next GC run,
at which point it will be fully destroyed, if possible.

GC counts change on a number of tests, as the objects now get
destroyed later.
2019-08-13 14:53:53 +02:00
Nikita Popov
1ae0b68404 Merge branch 'PHP-7.4' 2019-08-13 12:17:47 +02:00
Nikita Popov
72b7d99d0d Remove removed nested data from GC count 2019-08-13 12:17:08 +02:00
Nikita Popov
f0f3fe0b6c Don't include non-refcounted structures in GC count 2019-08-13 12:08:59 +02:00
Nikita Popov
9af705e753 Merge branch 'PHP-7.4' 2019-08-13 11:45:16 +02:00
Nikita Popov
7bd2b9d2e6 Generalize delref assertion
The refcount should never become negative, not just during GC.
2019-08-13 11:44:54 +02:00
Dmitry Stogov
172c71980d Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed handling of references in nested data of objects with destructor
2019-08-09 17:47:50 +03:00
Dmitry Stogov
4ebf527136 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed handling of references in nested data of objects with destructor
2019-08-09 17:47:35 +03:00
Dmitry Stogov
722a44d515 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed handling of references in nested data of objects with destructor
2019-08-09 17:47:06 +03:00
Dmitry Stogov
9b43e29d9b Fixed handling of references in nested data of objects with destructor 2019-08-09 17:43:50 +03:00
Dmitry Stogov
a037a5bd33 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed second part of the bug #78379 (Cast to object confuses GC, causes crash)
2019-08-09 15:58:44 +03:00
Dmitry Stogov
1456467cfe Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed second part of the bug #78379 (Cast to object confuses GC, causes crash)
2019-08-09 15:58:33 +03:00
Dmitry Stogov
22d23e08c9 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed second part of the bug #78379 (Cast to object confuses GC, causes crash)
2019-08-09 15:58:16 +03:00
Dmitry Stogov
6b1cc1252e Fixed second part of the bug #78379 (Cast to object confuses GC, causes crash) 2019-08-09 15:42:39 +03:00
Dmitry Stogov
9b973550b9 Merge branch 'PHP-7.4'
* PHP-7.4:
  Added asserts to catch GC errors when refcount goes below zero.
2019-08-09 13:40:56 +03:00
Dmitry Stogov
b2044cd93e Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Added asserts to catch GC errors when refcount goes below zero.
2019-08-09 13:40:39 +03:00
Dmitry Stogov
21a0a28fd0 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Added asserts to catch GC errors when refcount goes below zero.
2019-08-09 13:39:59 +03:00
Dmitry Stogov
2e2cd65d73 Added asserts to catch GC errors when refcount goes below zero. 2019-08-09 13:37:23 +03:00
Nikita Popov
e22633c4a7 Merge branch 'PHP-7.4' 2019-08-08 10:55:07 +02:00
Nikita Popov
d9dc942011 Merge branch 'PHP-7.3' into PHP-7.4 2019-08-08 10:55:02 +02:00
Nikita Popov
38f10ff5cf Fix GC tracing
Due to the GC changes in 7.3 we stopped tracing most of the
interesting coloring changes...
2019-08-08 10:54:18 +02:00
Dmitry Stogov
4d9e5ddf7c Merge branch 'PHP-7.4'
* PHP-7.4:
  Don't set GC_HAS_DESTRUCTORS flag if destructors were already called
  Update NEWS for 7.4.0beta3
  Update NEWS for PHP 7.4.0beta2
2019-08-06 11:37:08 +03:00
Dmitry Stogov
170a3f871f Don't set GC_HAS_DESTRUCTORS flag if destructors were already called 2019-08-06 11:35:53 +03:00
Nikita Popov
25985fedcf Merge branch 'PHP-7.4' 2019-07-15 13:49:36 +02:00
Nikita Popov
d60d16bda6 Merge branch 'PHP-7.3' into PHP-7.4 2019-07-15 13:49:29 +02:00
Nikita Popov
193f28c7d5 Fixed bug #78010
Prevent the gc_info from becoming all zero for a registered root
by setting the top bit to one for compressed root addresses.
2019-07-15 12:00:30 +02:00
Nikita Popov
3645292235 Merge branch 'PHP-7.4' 2019-06-19 15:09:39 +02:00
Nikita Popov
3d4298697b Fix shift UB in constants
We were shifting out the top bit of a signed integer.
2019-06-19 15:09:00 +02:00