Skip to content

Missing addref for Countable::count() #21605

Closed

Description

@iluuu1994

Description

Description

The following code:

<?php

class C implements Countable {
    public function count(): int {
        global $c;
        $c = null;
        var_dump($this);
        return 42;
    }
}

$c = new C;
var_dump(count($c));

Resulted in this output:

Segfault

But I expected this output instead:

Originally reported by @cnwangjihe.

PHP Version

PHP 8.2+

Operating System

No response

Activity

  1. added a commit that references this issue on Apr 2, 2026
    98aa427
  2. added a commit that references this issue on Apr 8, 2026
    8972938
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions