|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
23 + 20 = ?
Subscribe to this entry?

 [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-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 01 04:05:54 2022 UTC