php.net |  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: ircmaxell@php.net 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:
MUST BE VALID
Solve the problem:
14 + 16 = ?
Subscribe to this entry?

 
 [2019-03-07 14:43 UTC] 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;


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-07 14:43 UTC] ircmaxell@php.net
-Assigned To: +Assigned To: dmitry
 [2019-03-11 12:46 UTC] dmitry@php.net
-Status: Assigned +Status: Feedback
 [2019-03-11 12:46 UTC] dmitry@php.net
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 23 05:01:31 2024 UTC