Skip to content

A stdlib function called by runtime name with an object/array argument reads the pointer as string bytes instead of throwing TypeError. #332

Closed

Description

@blacktrs

Summary

A stdlib function called by runtime name with an object/array argument reads the pointer as string bytes instead of throwing TypeError.

Repro

<?php
class Conn {}
$f = 'ucfirst';
try { var_dump($f(new Conn)); } catch (\Throwable $e) { echo get_class($e), "\n"; }
try { var_dump($f([1])); } catch (\Throwable $e) { echo get_class($e), "\n"; }

Expected (php)

TypeError
TypeError

Actual (manticore f6ef51c5, Darwin arm64)

string(5) "�����"
string(1) "�"

Tracking

Known-bug repro: tests/aot/repro/wrong/dyn_name_stdlib_fn_object_arg.php — bash tests/aot/xfail.sh -k dyn_name_stdlib_fn_object_arg reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 18, 2026
  2. blacktrs commented on Oct 18, 2026

    @blacktrs
    ContributorAuthor

    Partly fixed on perf/basic-fns-sweep: the by-name thunk now feeds string parameters through the same string cast a direct call gets, so the pointer is no longer read as string bytes. What remains is the general cell->string coercion being lenient (object throws Error, array answers "Array" where php throws TypeError); the repro stays as XFAIL for that.

  3. blacktrs commented on Nov 12, 2026

    @blacktrs
    ContributorAuthor

    Reopening: PR #333 fixed the pointer-read half only. On main 55e1f1c the repro tests/aot/repro/wrong/dyn_name_stdlib_fn_object_arg.php is still XFAIL: $f = 'ucfirst'; $f(new Conn) throws Error and $f([1]) returns string(5) "Array"; php throws TypeError for both.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions