Bug #77708 [Asn->Fbk]: FFI Segfaults when using Closure::fromCallable

From: Date: Mon, 11 Mar 2019 12:46:05 +0000
Subject: Bug #77708 [Asn->Fbk]: FFI Segfaults when using Closure::fromCallable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219908@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77708&edit=1

 ID:                 77708
 Updated by:         dmitry@php.net
 Reported by:        ircmaxell@php.net
 Summary:            FFI Segfaults when using Closure::fromCallable
-Status:             Assigned
+Status:             Feedback
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   linux
 PHP Version:        Next Minor Version
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

The crash is fixed.
However, Closure::fromCallable() can not create closure for FFI function and throws exception
instead.


Previous Comments:
------------------------------------------------------------------------
[2019-03-07 14:43:03] ircmaxell@php.net

Description:
------------
When attempting to create a closure from an FFI function, it results in a segfault  when trying to
call the closure.

Test script:
---------------
<?php

$header = '
int printf(const char*, ...);

';

$ffi = FFI::cdef($header, 'libc.so.6');

$cb = Closure::fromCallable([$ffi, 'printf']);

$cb("Hello World\n");

Expected result:
----------------
Hello World

Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
0x0000555555ae0c0d in zend_closure_call_magic (execute_data=0x7ffff3a13180,
return_value=0x7ffff3a13100) at /.../Zend/zend_closures.c:249
249                     EX(func)->internal_function.scope->__callstatic :
EX(func)->internal_function.scope->__call;



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=77708&edit=1


Thread (3 messages)

« previous php.bugs (#219908) next »