php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78543 is_callable() on FFI\CData -> Exception: Attempt to call non C function pointer
Submitted: 2019-09-15 12:25 UTC Modified: 2019-09-23 13:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: asmqb7 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: *Extensibility Functions
PHP Version: 7.4.0RC1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: asmqb7 at gmail dot com
New email:
PHP Version: OS:

 

 [2019-09-15 12:25 UTC] asmqb7 at gmail dot com
Description:
------------
Unsure what's happening, so not going to make myself look silly with wild and probably incorrect guesses.

(Something something FFI\CData not being able to tell the difference between "are you callable" and actually being called... I'll be curious to read the patch.)

Just started playing with FFI, which is very fun. I look forward to the crazy and awesome things this is going to make possible. Thanks so much :)

Stumbled on this because my d() routine (generic-everything dumper) crashed in its type detector function. (NB. The testcase below drops is_callable()'s return value, since it makes no difference.)

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

$ffi = FFI::cdef(' struct test { int dummy; }; ');

$test = $ffi->new('struct test');

is_callable($test);

Expected result:
----------------
For is_callable() to return false

Actual result:
--------------
Fatal error: Uncaught FFI\Exception: Attempt to call non C function pointer in ...
Stack trace:
#0 ...: is_callable(Object(FFI\CData:struct test))


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-15 12:26 UTC] asmqb7 at gmail dot com
Semantic clarification: I'm using PHP7.4.0beta1, not 7.4.0RC1.
 [2019-09-18 09:59 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #78543: is_callable() on FFI\CData throws Exception
On GitHub:  https://github.com/php/php-src/pull/4718
Patch:      https://github.com/php/php-src/pull/4718.patch
 [2019-09-19 07:18 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9dfbcd7248012ac651a48eb871bfa58bb9e6c5d7
Log: Fix #78543: is_callable() on FFI\CData throws Exception
 [2019-09-19 07:18 UTC] cmb@php.net
-Status: Open +Status: Closed
 [2019-09-19 07:21 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2019-09-23 13:22 UTC] asmqb7 at gmail dot com
Awesome, thanks!

(And the patch is... yep, totally over my head :) very grateful for the fix)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC