Skip to content

Resolve UConverter callbacks after clone - #23324

Closed
iliaal wants to merge 1 commit into
php:PHP-8.5from
iliaal:fix/intl-uconverter-clone-callback
Closed

Resolve UConverter callbacks after clone#23324
iliaal wants to merge 1 commit into
php:PHP-8.5from
iliaal:fix/intl-uconverter-clone-callback

Conversation

@iliaal

@iliaal iliaal commented Aug 16, 2026

Copy link
Copy Markdown
Member

UConverter::__construct() fills to_cache/from_cache. clone never runs the constructor and only retargeted the ICU C callbacks, so the first callback-worthy convert called zend_call_known_fcc on a NULL handler. Both caches are now resolved in php_converter_object_ctor, covering construct and clone alike.

Comment thread ext/intl/converter/converter.c Outdated

zend_objects_clone_members(&(objval->obj), &(oldobj->obj));

php_converter_resolve_callback(&objval->to_cache, &objval->obj, ZEND_STRL("toUCallback"));

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.

--- a/ext/intl/converter/converter.c
+++ b/ext/intl/converter/converter.c
@@ -546,8 +546,6 @@ PHP_METHOD(UConverter, __construct) {
              ZEND_ASSERT(EG(exception));
              goto cleanup;
      }
-     php_converter_resolve_callback(&objval->to_cache, Z_OBJ_P(ZEND_THIS), ZEND_STRL("toUCallback"));
-     php_converter_resolve_callback(&objval->from_cache, Z_OBJ_P(ZEND_THIS), ZEND_STRL("fromUCallback"));
 cleanup:
      INTL_G(use_exceptions) = old_use_exception;
      INTL_G(error_level) = old_error_level;
@@ -916,6 +914,8 @@ static zend_object *php_converter_object_ctor(zend_class_entry *ce, php_converte
      zend_object_std_init(&objval->obj, ce);
      object_properties_init(&objval->obj, ce);
      intl_error_init(&(objval->error));
+     php_converter_resolve_callback(&objval->to_cache, &objval->obj, ZEND_STRL("toUCallback"));
+     php_converter_resolve_callback(&objval->from_cache, &objval->obj, ZEND_STRL("fromUCallback"));

      *pobjval = objval;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

@devnexen

Copy link
Copy Markdown
Member

well nvm, I clicked too fast, point not addressed ...

__construct filled to_cache/from_cache via php_converter_resolve_callback,
so a clone, which never runs the constructor, kept both FCCs zeroed and
the first callback-worthy convert called zend_call_known_fcc on a NULL
handler. Resolve both caches in php_converter_object_ctor so every
allocation path gets them.
@iliaal
iliaal force-pushed the fix/intl-uconverter-clone-callback branch from df55043 to 3b51aad Compare September 12, 2026 22:08
@iliaal iliaal closed this in 2311816 Sep 13, 2026
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