Closed
Description
Description
When working on symfony/symfony#59800, I faced a crash in the engine. The CI crashes on the added test:
/**
* @requires PHP 8.5
*/
public function testAttributesWithClosure()
{
$loader = new AttributeLoader();
$metadata = new ClassMetadata(WhenTestWithClosure::class);
self::assertTrue($loader->loadClassMetadata($metadata));
[$classConstraint] = $metadata->getConstraints();
// ...
}
After a short investigation, $loader->loadClassMetadata($metadata)
is the culprit. This happens when using closures in attributes, here is the fixtures that causes the crash:
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\When;
#[When(expression: static function () {
return true;
}, constraints: new NotNull()
)]
class WhenTestWithClosure
{
#[When(expression: static function () {
return true;
}, constraints: [
new NotNull(),
new NotBlank(),
])]
private $foo;
}
When running the test, the output is:
............................................................. 4758 / 5217 ( 91%)
.................................zend_mm_heap corrupted
zsh: abort ./phpunit src/Symfony/Component/Validator/Test
This can be reproduced by checking out this PR symfony/symfony#59800 and running with PHP 8.5:
./phpunit src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php
I tried to make a simpler reproducer but I wasn't able to. I'd be happy to help setting up the reproducer described if needed. Thanks!
PHP Version
8.5
Operating System
macOS 15.3.1