Skip to content

Segmentation fault in FFI #16324

@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
require_once('utils.inc');
$zend = FFI::cdef("
typedef size_t (*zend_write_func_t)(const char *str, size_t str_length);
extern zend_write_func_t zend_write;
", ffi_get_php_dll_name());
$zend->zend_write = $fusion;
echo "Hello World!\n";

Resulted in this output:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==2090797==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000000000 bp 0x7ffc0ff57fc0 sp 0x7ffc0ff57ea8 T0)
==2090797==Hint: pc points to the zero page.
==2090797==The signal is caused by a READ memory access.
==2090797==Hint: address points to the zero page.
    #0 0x0  (<unknown module>)
    #1 0x557a64243713 in execute_ex /php-src/Zend/zend_vm_execute.h:58565:7
    #2 0x557a64245872 in zend_execute /php-src/Zend/zend_vm_execute.h:64217:2
    #3 0x557a64f45b01 in zend_execute_script /php-src/Zend/zend.c:1928:3
    #4 0x557a63856798 in php_execute_script_ex /php-src/main/main.c:2574:13
    #5 0x557a63857858 in php_execute_script /php-src/main/main.c:2614:9
    #6 0x557a64f59276 in do_cli /php-src/sapi/cli/php_cli.c:935:5
    #7 0x557a64f53944 in main /php-src/sapi/cli/php_cli.c:1310:18
    #8 0x7f16ef89dd8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 490fef8403240c91833978d494d39e537409b92e)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (<unknown module>) 
==2090797==ABORTING

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