php / php/doc-en

Destruction segmentation fault for deeply nested objects

Open
#1,228 10 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Category: Engine
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

Description

The following code:

<?php

abstract class LinkedList { }

final class Cons extends LinkedList
{
    public function __construct(
        public mixed $head,
        public LinkedList $tail
    ) { }
}

final class Nil extends LinkedList { }

$list = new Nil();

for ($i = 0; $i < 100000; $i++) {
    $list = new Cons(random_int(0, PHP_INT_MAX), $list);
}

Resulted in this output:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

But I expected this output instead:

Process finished with exit code 0
PHP Version

PHP 8.0.13 (cli)

Operating System

Ubuntu 20.04

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided PHP script with PHP 8.0.13 on Ubuntu 20.04 and confirm the SIGSEGV after creating 100,000 nested objects. The issue does not name a documentation file, test, or proposed change; resolution would require identifying the relevant PHP runtime behavior rather than an obvious edit in this repository.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.