Skip to content

pcre: various minor refactorings (2026-09 N1) - #23536

Draft
Girgias wants to merge 7 commits into
php:masterfrom
Girgias:2026-09-pcre-minor-refactoring
Draft

pcre: various minor refactorings (2026-09 N1)#23536
Girgias wants to merge 7 commits into
php:masterfrom
Girgias:2026-09-pcre-minor-refactoring

Conversation

@Girgias

@Girgias Girgias commented Sep 1, 2026

Copy link
Copy Markdown
Member

No description provided.

Comment thread ext/pcre/php_pcre.c

if (key != regex) {
zv = zend_hash_str_lookup(&char_tables, ZSTR_VAL(BG(ctype_string)), ZSTR_LEN(BG(ctype_string)));
zv = zend_hash_lookup(&char_tables, BG(ctype_string));

@devnexen devnexen Sep 2, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only change that concerns me a bit. would it be possible to try at least locally this change (with ASAN) ?

❯ can you draft a test to trigger this issue ?zm_globals_dtor_pcre → zend_hash_destroy(&char_tables)).

--TEST--
preg_match(): locale-keyed char tables cache must not borrow a request-lifetime key
--SKIPIF--
<?php
if (setlocale(LC_CTYPE, 'C.UTF-8', 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8') === false) {
    die('skip no suitable non-C locale available');
}
?>
--FILE--
<?php
var_dump(setlocale(LC_CTYPE, 'C.UTF-8', 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8') !== false);
setlocale(LC_CTYPE, setlocale(LC_CTYPE, 0));
var_dump(preg_match('/[[:alpha:]]/', 'a'));
?>
--EXPECT--
bool(true)
int(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants