- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Description
Description
When working onsymfony/symfony#59800, I faced a crash in the engine. TheCI crashes on the added test:
/** * @requires PHP 8.5 */publicfunctiontestAttributesWithClosure(){$loader =newAttributeLoader();$metadata =newClassMetadata(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:
useSymfony\Component\Validator\Constraints\NotBlank;useSymfony\Component\Validator\Constraints\NotNull;useSymfony\Component\Validator\Constraints\When;#[When(expression:staticfunction () {returntrue; }, constraints:newNotNull())]class WhenTestWithClosure{ #[When(expression:staticfunction () {returntrue; }, constraints: [newNotNull(),newNotBlank(), ])]private$foo;}
When running the test, the output is:
............................................................. 4758 / 5217 ( 91%).................................zend_mm_heap corruptedzsh: abort ./phpunit src/Symfony/Component/Validator/Test
This can be reproduced by checking out this PRsymfony/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