Internal pointer past the end resets to the first element on copy-on-write separation
@iliaal y travaille déjà.
Depuis le 8/9/2026.
Évaluation
Cette issue n'a pas encore été évaluée.
Description
Description
end() followed by next() leaves the internal pointer past the end, so key() returns NULL. A copy-on-write separation then moves it back to the first element instead of leaving it past the end. An in-range pointer survives the same separation unchanged, and the untouched copy keeps NULL, so the past-the-end case is the only one that moves.
The following code:
<?php
$a = ['a' => 1, 'b' => 2, 'c' => 3];
end($a);
next($a);
var_dump(key($a), current($a));
$b = $a;
$a['d'] = 4;
var_dump(key($a), current($a));
Resulted in this output:
NULL
bool(false)
string(1) "a"
int(1)
But I expected this output instead:
NULL
bool(false)
NULL
bool(false)
zend_array_dup() clamps the copied pointer with (source->nInternalPointer < source->nNumUsed) ? source->nInternalPointer : 0 at Zend/zend_hash.c:2511 for the mixed case and :2495 for the packed case. The immutable branch at :2479 copies it verbatim, so the three arms of that function disagree.
PHP Version
PHP 8.4.25, also PHP-8.4 and master at d26d5f2
Operating System
Linux
- Langage dominant
- C
- Étoiles
- 40.4k
- Forks
- 8.2k
- Merge moyen
- 2 j 17 h
- PR mergées (30 j)
- 115
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de php/php-src
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
Bug Status: Needs Triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Flaky hrtime.phpt test OuverteBug Category: Tests Status: Verified
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Bug SAPI: fpm Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Toutes les issues de php/php-src
Issues similaires
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 60/100
-
Nmap
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
flang:fir-hlfir
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
llvm/llvm-project#225935 ·