History log of /PHP-8.4/Zend/zend_hash.c (Results 1 – 25 of 481)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 2bdce613 31-Oct-2024 Ilija Tovilo

Fix array going away during sorting

Fixes GH-16648
Closes GH-16654


# fdd6ba62 25-Sep-2024 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Fix GH-16054: Segmentation fault when resizing hash table iterator list while adding

zend_array_dup_ht_iterators() loops over the hash table iterators and
can call zend_hash_iterator_add

Fix GH-16054: Segmentation fault when resizing hash table iterator list while adding

zend_array_dup_ht_iterators() loops over the hash table iterators and
can call zend_hash_iterator_add(). zend_hash_iterator_add() can resize
the array causing a crash in zend_array_dup_ht_iterators().

We solve this by refetching the iter pointer after an add happened.

Closes GH-16060.

show more ...


# 82479e89 22-Jul-2024 Ilija Tovilo

Throw error for recursive comparison, instead of fatal (#14989)

I don't understand the rationale of fatal erroring here. It seems this should
properly unprotect the compared elements whe

Throw error for recursive comparison, instead of fatal (#14989)

I don't understand the rationale of fatal erroring here. It seems this should
properly unprotect the compared elements when returning up the stack.

Related to GH-14980

show more ...


# c3a5b987 02-Jul-2024 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Add zend_hash_get_current_pos_ex() (#14770)


# 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.


# 8f66b67c 10-May-2023 Ilija Tovilo

Fix compilation for PHP 8.1

Accidentally introduced in 175ff603c3a8ae9dd3e6ccb3fc3081b06263f989. arData was
not part of an anonymous union.


# 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
# 14fddd17 04-Apr-2022 Dmitry Stogov

Fix arsort() crash on recursion

Fixes oss-fuzz #46315


12345678910>>...20