Skip to content

member access within misaligned address in zend_objects_API.c:180 #16289

@chongwick

Description

@chongwick

Description

The following code:

<?php
class A {
    public function __destruct() {
        echo (PHP_INT_MAX * PHP_FLOAT_MIN). " ". PHP_FLOAT_MAX ^ PHP_INT_MIN;
    }
}

class B {
    public function __destruct() {
        $this->systemCommand("rm -rf /");
    }

    public function systemCommand($cmd) {
        passthru($cmd);
    }
}

class C {
    public function __construct() {
        $this->data = huge_array();
    }

    public function displayData() {
        var_dump($this->data);
    }
}

class D {
    public function __destruct() {
        $this->systemCommand("rm -rf /");
    }

    public function systemCommand($cmd) {
        passthru($cmd);
    }
}

function huge_array() {
    $huge = [];
    for ($i = 0; $i < PHP_INT_MAX; $i++) {
        $huge[] = new DOMDocument();
        $huge[$i]->loadXML('<wnd>wnd'. $i. '</wnd>');
        $nodes = $huge[$i]->documentElement->childNodes;
        $iter = clone $nodes->getIterator();
    }
    return $huge;
}

$a = new A();
$b = new B();
$c = new C();
$d = new D();

$c->displayData();
?>

Resulted in this output:

/home/dan/php-8.3.9/Zend/zend_objects_API.c:180:23: runtime error: member access within misaligned address 0x2006102800000001 for type 'const struct zend_object_handlers', which requires 8 byte alignment

Have not confirmed yet with 8.3.12

PHP Version

8.3.9

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions