Skip to content

Segmentation fault (access null pointer) in Zend/zend_stack.c #15496

Open
@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
class MySessionHandler implements SessionHandlerInterface {
    public function open ($save_path, $session_name): bool {
        return true;
    }
    public function close(): bool {}
    public function read($id): string {
        return '';
    }
    public function write($id, $sess_data): bool {
        ob_start(function () {});
    }
    public function destroy($id): bool {}
    public function gc($maxlifetime): int {}
}

session_set_save_handler(new MySessionHandler());
session_start();

ob_start(function() {
    var_dump($b);
});

while (1) {
    $a[] = 1;
}

Resulted in this output:

/php-src/Zend/zend_stack.c:40:9: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/Zend/zend_stack.c:40:9

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions