Skip to content

Segfault during ->getContent() on a phar with recursive symlinks #21986

@edorian

Description

@edorian

Description

The following code:

<?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

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions