[php-src] Issue #21986: Segfault during `->getContent()` on a `phar` with recursive symlinks

[email protected] (edorian)
Newsgroups php.bugs
Message-ID <5OZBrxZX5NaP1Z7swQWwWA7G4TrevlIGU6Ac56Eo7oY@main.internal.php.net>
Issue: https://github.com/php/php-src/issues/21986
Author: edorian

### Description

The following code:

```php
<?php

$dir = '/tmp/phar_test';
mkdir($dir . '/content', 0777, true);
chdir($dir . '/content');
symlink('b.txt', 'a.txt');
symlink('a.txt', 'b.txt');
exec("tar cf $dir/test.tar a.txt b.txt");
$phar = new PharData("$dir/test.tar");
$phar['a.txt']->getContent();
```

Resulted in this output:
```
[1]    6676 segmentation fault  php reproduce.php
```

But I expected this output instead:
```
Some kind of error
```


### PHP Version

```plain
PHP 8.5.6 (cli) (built: May  5 2026 21:19:36) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.5.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.6, Copyright (c), by Zend Technologies
```

### Operating System

macOS
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.