Skip to content

php-apache-dev:8.1-alpine ReflectionAttribute::newInstance segmentation fault; non-dev images work fine #538

@jurchiks

Description

@jurchiks

docker-compose.yml:

services:
    app:
        image: webdevops/php-apache-dev:8.1-alpine
        working_dir: /app
        volumes:
            - ./:/app:rw,cached

test.php:

<?php
#[Attribute(Attribute::TARGET_CLASS)]
final class Table {
    public function __construct(public readonly string $name) {}
}

#[Table('users')]
class TestClass {}

$testClass = new TestClass();
$attributes = (new ReflectionClass($testClass))->getAttributes();
var_dump($attributes);
foreach ($attributes as $attribute) {
    var_dump($attribute->newInstance());
}

The problem:

3948cef7d689:/app# php test.php
array(1) {
  [0]=>
  object(ReflectionAttribute)#3 (0) {
  }
}
Segmentation fault
3948cef7d689:/app#

I tested webdevops/php:8.1-alpine, and this same code worked there as expected.
I tested webdevops/php-apache:8.1-alpine, and this also worked as expected.
I tested webdevops/php-dev:8.1-alpine, and this failed.
I tested webdevops/php-dev:8.2-alpine, and this worked.
I tested webdevops/php-dev:8.3-alpine, and this worked.
I tested php:8.1-fpm-alpine, and this worked!
Clearly, something about the -dev version of specifically your flavor of PHP 8.1 fails.
Maybe also 8.0, but I have no need to test it as it's in the past.

For the record, I was upgrading from webdevops/php-apache-dev:7.3-alpine, which was also working fine, so the window of error is very narrow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions