|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77708 FFI Segfaults when using Closure::fromCallable
Submitted: 2019-03-07 14:43 UTC Modified: 2019-03-24 04:22 UTC
From: Assigned: dmitry (profile)
Status: No Feedback Package: Unknown/Other Function
PHP Version: Next Minor Version OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2019-03-07 14:43 UTC]
When attempting to create a closure from an FFI function, it results in a segfault  when trying to call the closure.

Test script:

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


$ffi = FFI::cdef($header, '');

$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;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-07 14:43 UTC]
-Assigned To: +Assigned To: dmitry
 [2019-03-11 12:46 UTC]
-Status: Assigned +Status: Feedback
 [2019-03-11 12:46 UTC]
The crash is fixed.
However, Closure::fromCallable() can not create closure for FFI function and throws exception instead.
 [2019-03-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 07:01:30 2024 UTC