Skip to content

Segmentation fault (zend_mm_heap corrupted) with pipe operator #21748

Description

@adrianszczotkowski

Description

Step 1:
The following code:

function test(string $string): void
{
    echo $string . PHP_EOL;
}

'abc' |> test(...);

Running with extra debug output :

php -e -n ./test.php

As expected returns:

abc

Step 2:
Add a file const.php

<?php

define('OPQ', false);

And require it in test.php:

require_once __DIR__ . '/const.php';

Run the same command:

php -e -n ./test.php

Returns:

zend_mm_heap corrupted

Step 3:
But add another define in test.php

require_once 'const.php';

define('XYZ', false);

function test(string $string): void
{
    echo $string . PHP_EOL;
}

'abc' |> test(...);

Run the same command:

php -e -n ./test.php

Works fine and returns:

abc

Bonus content:
Try the steps above without -n:

php -e ./test.php

Returns random content eg.:

<�V

PHP Version

PHP 8.5.5 (cli) (built: Apr  9 2026 22:14:17) (ZTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.5.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.5, Copyright (c), by Zend Technologies

Operating System

Linux 88a458a84760 6.19.12-1-cachyos #1 SMP PREEMPT_DYNAMIC Sat, 11 Apr 2026 19:24:21 +0000 x86_64 GNU/Linux

Activity

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