[php-src] Issue #21748: Segmentation fault (zend_mm_heap corrupted) with pipe operator

[email protected] (adrianszczotkowski)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/21748
Author: 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

```plain
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.