Skip to content

An FFI binding declared to return \Ffi\Ptr gives PHP null for a C NULL, so ->isNull() is a fatal error #401

Closed

Description

@blacktrs

Summary

An FFI binding declared to return \Ffi\Ptr gives PHP null for a C NULL, so ->isNull() is a fatal error.

Repro

<?php
use Ffi\Library;
use Ffi\Symbol;
use Ffi\Ptr;

#[Library('c'), Symbol('strchr')]
function strchr_(string $s, #[\Ffi\CType('int')] int $c): Ptr { return Ptr::null(); }

$p = strchr_('hello', 120);
var_dump($p->isNull());

Expected (php)

bool(true)

Actual (manticore 844dd6cd, Darwin arm64)


[exit code 255]
PHP Fatal error:  Uncaught Error: Call to a member function isNull() on null

Tracking

Known-bug repro: tests/aot/repro/wrong/ffi_ptr_null_return_is_php_null.php — bash tests/aot/xfail.sh -k ffi_ptr_null_return_is_php_null 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 23, 2026
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