History log of /php-src/Zend/zend_hash.c (Results 1 – 25 of 496)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# d6536468 18-Jan-2024 Ilija Tovilo

Fix iterator position resetting

Previously, when an array was converted from packed to hashed, iterators would
not be correctly reset to 0. Similarly, removing the last element from an a

Fix iterator position resetting

Previously, when an array was converted from packed to hashed, iterators would
not be correctly reset to 0. Similarly, removing the last element from an array
would decrease nNumUsed but not actually fix the iterator position, causing the
element to be skipped in the next iteration.

Some code was also removed that skips over IS_UNDEF elements for
nInternalPointer and iterator positions. This is unnecessary, as this already
happens during iteration.

Closes GH-13178
Closes GH-13188

show more ...


# b175ea42 29-Nov-2023 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Fix GH-12826: Weird pointers issue in nested loops

This regressed in cd53ce838a.
The loop with `zend_hash_iterators_update` hangs forever because
`iter_pos` can't advance to idx. Thi

Fix GH-12826: Weird pointers issue in nested loops

This regressed in cd53ce838a.
The loop with `zend_hash_iterators_update` hangs forever because
`iter_pos` can't advance to idx. This is because the
`zend_hash_iterators_lower_pos` upper bound is `target->nNumUsed`,
but that is set to `source->nNumOfElements`.
That means that if there are holes in the array, we still loop over all
the buckets but the number of bucket slots will not match.
Fix it by changing the assignment.

Closes GH-12831.

show more ...


# cd53ce83 16-May-2023 Bob Weinand

Track HashTableIterators for copy-on-write copies of HashTables

When executing a foreach ($ht as &$ref), foreach calls zend_hash_iterator_pos_ex() on every iteration. If the HashTable contai

Track HashTableIterators for copy-on-write copies of HashTables

When executing a foreach ($ht as &$ref), foreach calls zend_hash_iterator_pos_ex() on every iteration. If the HashTable contained in the $ht variable is not the tracked HashTable, it will reset the position to the internal array pointer of the array currently in $ht.
This behaviour is generally fine, but undesirable for copy-on-write copies of the iterated HashTable. This may trivially occur when the iterated over HashTable is assigned to some variable, then the iterated over variable modified, leading to array separation, changing the HashTable pointer in the variable. Thus foreach happily restarting iteration.
This behaviour (despite existing since PHP 7.0) is considered a bug, if not only for the behaviour being unexpected to the user, also copy-on-write should not have trivially observable side-effects by mere assignment.

The bugfix consists of duplicating HashTableIterators whenever zend_array_dup() is called (the primitive used on array separation).
When a further access to the HashPosition through the HashTableIterators API happens and the HashTable does not match the tracked one, all the duplicates (which are tracked by single linked list) are searched for the wanted HashTable. If found, the HashTableIterator is replaced by the found copy and all other copies are removed.
This ensures that we always end up tracking the correct HashTable.

Fixes GH-11244.

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>

show more ...


# af77d3b8 21-Jul-2023 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Fix GH-11716: cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1

Closes GH-11757.


# 975d28e2 10-May-2023 Bob Weinand

Fix GH-11222: foreach by-ref may jump over keys during a rehash

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>


# 175ff603 09-May-2023 Amedeo Baragiola

Fix compilation error on old GCC versions

In older versions of GCC (<=4.5) designated initializers would not accept member
names nested inside anonymous structures. Instead, we need to u

Fix compilation error on old GCC versions

In older versions of GCC (<=4.5) designated initializers would not accept member
names nested inside anonymous structures. Instead, we need to use a positional
member wrapped in {}.

Fixes GH-11063
Closes GH-11212

show more ...


# 05bd1423 05-May-2023 Bob Weinand

Fix GH-11189: Exceeding memory limit in zend_hash_do_resize leaves the array in an invalid state

There are more places in zend_hash.c where the resize happened after some values on the HashT

Fix GH-11189: Exceeding memory limit in zend_hash_do_resize leaves the array in an invalid state

There are more places in zend_hash.c where the resize happened after some values on the HashTable struct were set.
I reordered them all, but writing a test for these would rely on the particular amount of bytes allocated at given points in time.

show more ...


# e2f477c2 28-Apr-2023 ColinHDev

Fix negative indices on empty array not affecting next chosen index

Changed the value of nNextFreeElement in _zend_empty_array from 0 to
ZEND_LONG_MIN.

Fixes GH-11154
Closes

Fix negative indices on empty array not affecting next chosen index

Changed the value of nNextFreeElement in _zend_empty_array from 0 to
ZEND_LONG_MIN.

Fixes GH-11154
Closes GH-11157

show more ...


# d835de19 17-Mar-2023 Tony Su

[zend_hash]: Use AVX2 instructions for better code efficiency (#10858)

We prefer to use AVX2 instructions for code efficiency improvement
1) Reduce instruction path length
Generic

[zend_hash]: Use AVX2 instructions for better code efficiency (#10858)

We prefer to use AVX2 instructions for code efficiency improvement
1) Reduce instruction path length
Generic x86 Instr: 16, SSE2: 6, AVX2: 4
2) Better ICache locality and density

To enable AVX2 instructions, compile with '-mavx2' option via CFLAGS
environment variable or command line argument.

Note: '-mavx' option still leads to using SSE2 instructions.
_mm256_cmpeq_epi64() requires AVX2 (-mavx2).

Testing:
Build with and without '-mavx2', 'make TEST_PHP_ARGS=-j8 test'
presented the same test report.

Signed-off-by: Tony Su <tao.su@intel.com>

show more ...


# 2d3427c5 16-Jan-2023 Christoph M. Becker

Revert "#include cleanup (#10216)"

Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit e628c66f9d4173e585081ddef358505433f9a288.


# 2b190778 13-Jan-2023 Arnaud Le Blanc

zend_hash_check_size: allow nSize <= HT_MAX_SIZE (#10244)

This is consistent with other uses of HT_MAX_SIZE


# 0f7625c4 13-Jan-2023 Arnaud Le Blanc

Reduce HT_MAX_SIZE to account for the max load factor of 0.5 (#10242)

zend_hash allocates a hash table twice as big as nTableSize
(HT_HASH_SIZE(HT_SIZE_TO_MASK(nTableSize)) == nTableSize

Reduce HT_MAX_SIZE to account for the max load factor of 0.5 (#10242)

zend_hash allocates a hash table twice as big as nTableSize
(HT_HASH_SIZE(HT_SIZE_TO_MASK(nTableSize)) == nTableSize*2), so HT_MAX_SIZE
must be half the max table size or less.

Fixes GH-10240

show more ...


# e628c66f 04-Jan-2023 Max Kellermann

#include cleanup (#10216)

Shift header include

In the C file, include the header first so missing #includes are
detected by the compiler, and use lighter header dependencies in

#include cleanup (#10216)

Shift header include

In the C file, include the header first so missing #includes are
detected by the compiler, and use lighter header dependencies in the
header, to speed up compile times.

show more ...


# 86456574 02-Nov-2022 George Peter Banyard

Fix performance degradation introduced in c2547ab7dc67646e287d430e44798cb9f327cf21

After discussing with someone, our current running theory is that the local
variable forces the compile

Fix performance degradation introduced in c2547ab7dc67646e287d430e44798cb9f327cf21

After discussing with someone, our current running theory is that the local
variable forces the compiler to reserve an additional register for the whole
lifespan of the function. Dropping it and just loading the value should restore
the previous code generation.

Closes GH-9876

show more ...


# db012a8b 04-Oct-2022 Jorg Adam Sowa

Use function HT_IS_PACKED where it's missing (#9658)


Revision tags: php-8.2.0RC1, php-8.1.10, php-8.0.23, php-8.0.23RC1, php-8.1.10RC1, php-8.2.0beta3, php-8.2.0beta2, php-8.1.9, php-8.0.22
# 3a843f95 24-Jul-2022 dixyes

Windows arm64 zend and standard extension support

* Port zend_cpuid for windows arm64
* Fix zend_atomic windows arm64 build
* Fix windows arm64 multiply
* Enable arm64 neon for w

Windows arm64 zend and standard extension support

* Port zend_cpuid for windows arm64
* Fix zend_atomic windows arm64 build
* Fix windows arm64 multiply
* Enable arm64 neon for windows in standard extension
* Enable arm64 neon for windows in zend_hash.c
* Workaround for msvc arm64 optimization bug

Closes GH-9115.

show more ...

# faa83f2f 04-Aug-2022 George Peter Banyard

Convert some macros to zend_always_inline functions (#8288)

This doesn't have an effect really, but humans and IDEs can struggle to see through the macro soup when they first interact with P

Convert some macros to zend_always_inline functions (#8288)

This doesn't have an effect really, but humans and IDEs can struggle to see through the macro soup when they first interact with PHP's source code.

Moreover, this reduces some of the macro expansion hell when they appear in compiler warnings.

show more ...

Revision tags: php-8.1.9RC1, php-8.2.0beta1, php-8.0.22RC1
# 75a9a5f3 11-Jul-2022 Tim Düsterhus

Add `zend_array_to_list()` (#8976)

* Add zend_array_to_list()

* Use `zend_array_to_list()` in `PHP_FUNCTION(array_values)`

Revision tags: php-8.0.21, php-8.1.8, php-8.2.0alpha3, php-8.1.8RC1, php-8.2.0alpha2, php-8.0.21RC1, php-8.0.20, php-8.1.7, php-8.2.0alpha1, php-7.4.30, php-8.1.7RC1, php-8.0.20RC1, php-8.1.6, php-8.0.19, php-8.1.6RC1, php-8.0.19RC1
# c2547ab7 20-Apr-2022 George Peter Banyard

Add some const qualifiers in zend_string/hash (#8304)

Co-authored-by: Levi Morrison <morrison.levi@gmail.com>

Revision tags: php-8.0.18, php-8.1.5, php-7.4.29
# 2ab05da9 04-Apr-2022 Dmitry Stogov

Merge branch 'PHP-8.1'

* PHP-8.1:
Fix arsort() crash on recursion


# 14fddd17 04-Apr-2022 Dmitry Stogov

Fix arsort() crash on recursion

Fixes oss-fuzz #46315

Revision tags: php-8.1.5RC1
# b9e895bc 31-Mar-2022 Max Kellermann

Replace memcmp() with zend_string functions (#8216)

* ext/oci8: use zend_string_equals()

Eliminate duplicate code.

* main/php_variables: use zend_string_equals_literal()

Replace memcmp() with zend_string functions (#8216)

* ext/oci8: use zend_string_equals()

Eliminate duplicate code.

* main/php_variables: use zend_string_equals_literal()

Eliminate duplicate code.

* Zend/zend_string: add zend_string_equals_cstr()

Allows eliminating duplicate code.

* Zend, ext/{opcache,standard}, main/output: use zend_string_equals_cstr()

Eliminate duplicate code.

* Zend/zend_string: add zend_string_starts_with()

* ext/{opcache,phar,spl,standard}: use zend_string_starts_with()

This adds missing length checks to several callers, e.g. in
cache_script_in_shared_memory(). This is important when the
zend_string is shorter than the string parameter, when memcmp()
happens to check backwards; this can result in an out-of-bounds memory
access.

show more ...

Revision tags: php-8.0.18RC1, php-8.1.4, php-8.0.17, php-8.1.4RC1, php-8.0.17RC1, php-8.1.3, php-8.0.16, php-7.4.28, php-8.1.3RC1, php-8.0.16RC1, php-8.1.2, php-8.0.15, php-8.1.2RC1, php-8.0.15RC1
# eee3b1d9 24-Dec-2021 Dmitry Stogov

Bucket->key must be removed before destructor call, because destructor may update the same HashTable.

Fixes oss-fuzz #42894

# 5d6bc250 22-Dec-2021 Dmitry Stogov

Reset Bucket->key of deleted HastTable elemets to NULL.

This allows elimination of some Z_ISUNDEF(Bucket->val) checks.

Revision tags: php-8.0.14, php-8.1.1, php-7.4.27, php-8.1.1RC1, php-8.0.14RC1, php-7.4.27RC1, php-8.1.0
# d3f073e8 22-Nov-2021 Dmitry Stogov

Remove useless check

12345678910>>...20