Bug #78474 [Opn->Nab]: FFI::scope does not work in CLI SAPI
| From: | cmb@php.net | Date: | Thu, 29 Aug 2019 08:15:28 +0000 |
| Subject: | Bug #78474 [Opn->Nab]: FFI::scope does not work in CLI SAPI | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222479@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78474&edit=1
ID: 78474
Updated by: cmb@php.net
Reported by: ojrask at gmail dot com
Summary: FFI::scope does not work in CLI SAPI
-Status: Open
+Status: Not a bug
Type: Bug
Package: Unknown/Other Function
Operating System: Ubuntu 18.04
PHP Version: 7.4.0beta4
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
From the docs[1]:
| Instantiates an FFI object with C declarations parsed during
| preloading.
Previous Comments:
------------------------------------------------------------------------
[2019-08-29 08:00:20] ojrask at gmail dot com
Description:
------------
When I attempt to use
\FFI::scope() in CLI scripts (no preloading and all that jazz), I
get an error saying
PHP Fatal error: Uncaught FFI\Exception: Failed loading scope 'FOO' in ...
The stack trace reveals no reasons. I would presume scopes are OK to be used in CLI SAPI, or then
there is some documentation missing as to why it is not possible.
Test script:
---------------
<?php declare(strict_types = 1);
$header = <<<'HEA'
#define FFI_SCOPE "FOO"
#define FFI_LIB "libc.so.6"
void printf(char *const str, ...);
'HEA';
file_put_contents(__DIR__ . '/header.h', $header);
\FFI::load(__DIR__ . '/header.h');
$ffi = \FFI::scope('FOO');
$ffi->printf('Hello %s!', 'world');
Expected result:
----------------
Output should be
Hello world!
Actual result:
--------------
Output is
PHP Fatal error: Uncaught FFI\Exception: Failed loading scope 'FOO' in
.../hello-world.php:14
Stack trace:
#0 .../hello-world.php(14): FFI::scope()
#1 {main}
thrown in .../hello-world.php on line 14
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78474&edit=1