Segmentation fault (access null pointer) in Zend/zend_stack.c
Open
Nobody has claimed this yet.
Bug
Category: Output
Status: Verified
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided PHP script under UBSan and inspect Zend/zend_stack.c at line 40, where the null-pointer diagnostic is reported. Compare the runtime behavior with the session and output-buffer callbacks in the example; done means the reproducer no longer triggers the segmentation fault or UBSan report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100