History log of /PHP-8.3/Zend/zend_hash.c (Results 1 – 25 of 509)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 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 ...

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

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

Merge branch 'PHP-8.2'

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


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

Merge branch 'PHP-8.1' into PHP-8.2

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


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

# 0787247b 10-May-2023 Bob Weinand

Merge branch 'PHP-8.2'


# 53558ffc 10-May-2023 Bob Weinand

Merge branch 'PHP-8.1' into PHP-8.2


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

# 7304b56f 10-May-2023 Ilija Tovilo

Merge branch 'PHP-8.2'

* PHP-8.2:
Fix compilation error on old GCC versions


# 66924774 10-May-2023 Ilija Tovilo

Merge branch 'PHP-8.1' into PHP-8.2

* PHP-8.1:
Fix compilation error on old GCC versions


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

# a9d11b64 05-May-2023 Bob Weinand

Merge branch 'PHP-8.2'


# cfbb47b5 05-May-2023 Bob Weinand

Merge branch 'PHP-8.1' into PHP-8.2


# 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

# ba091ab3 13-Jan-2023 Arnaud Le Blanc

Merge branch 'PHP-8.2'

* PHP-8.2:
[ci skip] NEWS
Reduce HT_MAX_SIZE to account for the max load factor of 0.5 (#10242)
GC fiber unfinished executions (#9810)


# d8940807 13-Jan-2023 Arnaud Le Blanc

Merge branch 'PHP-8.1' into PHP-8.2

* PHP-8.1:
Reduce HT_MAX_SIZE to account for the max load factor of 0.5 (#10242)
GC fiber unfinished executions (#9810)


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

12345678910>>...21