Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107930 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34841 invoked from network); 19 Dec 2019 20:38:01 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 19 Dec 2019 20:38:01 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id F32162C04EC for ; Thu, 19 Dec 2019 10:38:27 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 66.111.4.0/24 X-Spam-Virus: No Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 19 Dec 2019 10:38:27 -0800 (PST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id E8964226CC for ; Thu, 19 Dec 2019 13:38:26 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Thu, 19 Dec 2019 13:38:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=st9sBIIuOKnY34C0HWseqaX1iFs4o zv8LKkgAViLIWI=; b=l2FTo8IWz0iRyvHDSQsxK7VJ3vxw3Dum8DwBGAV1QL9wE XGydn2IugTeY9bKC7sBn2z9PxYPRnquwP9pUhICKwfajacu8f7Em/oNz91hh+nc5 G6KvNVVmI9sh94Stsi9mKGVmv6dv05dEHaDsUeszsi0ZdkK0hdIxfvTzdElAgJn+ 1oGfb1qQs49dD+LV9tXoXpjfWZ2V3ENDPachVvOlHp/ZW9caZzFTs2EfsZ8ETEKA zuPnicsl7mFPbRX1akSdvAGMQvxSCFJk/frrtcNXThKtx1Ua3k68aLerOyobpMMq 0R5pd8VPnVTHFBB8pQUnTt+qOgjKGhp5bLPW38mZw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdduuddguddugecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuffhomhgrihhnpehphhhprdhnvghtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehl rghrrhihsehgrghrfhhivghlughtvggthhdrtghomhenucevlhhushhtvghrufhiiigvpe dt X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7477F14200A1; Thu, 19 Dec 2019 13:38:26 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-694-gd5bab98-fmstable-20191218v1 Mime-Version: 1.0 Message-ID: <8d5d9905-f1f8-4756-bb98-0604db21840b@www.fastmail.com> Date: Thu, 19 Dec 2019 12:38:06 -0600 To: "php internals" Content-Type: text/plain X-Envelope-From: Subject: Inconsistent default configuration and docs for FFI From: larry@garfieldtech.com ("Larry Garfield") I'm trying to experiment with FFI, and ran into an issue with PHP's default configuration. Or at least I believe it's the default configuration; I'm using Ondre's PPAs for Ubuntu. Let me try and lay out the moving parts: The default ini settings that are in play: opcache.enable => On => On opcache.enable_cli => Off => Off opcache.preload => no value => no value ffi.enable => preload => preload ffi.preload => no value => no value That is, by default, FFI only works in preloaded files or on the cli. This makes sense. Opcache is enabled by default. This makes sense. Opcache is disabled by default on the CLI, since the whole engine shuts down after the command finishes so it wouldn't be cached anyway. This makes sense. Because opcache is disabled for the CLI, the opcache.preload directive is ignored even if specified. This makes sense. As near as I can tell from playing with it, using FFI::load() and FFI::scope() work only with preloading. Or at least, following the documentation I've not figured out how to get them to work otherwise. So now, we have a default case where FFI (or some portion of it) only works with preloading, but opcache is disabled on the CLI, so preloading is diabled on the CLI, so FFI doesn't work out of the box. This... only makes sense after the fact but at the time makes no sense at all! And the error message you get is not at all helpful; it just throws an exception "Failed loading scope", which in no way indicates what the actual problem is. The result is that, if coming from a default configuration, this example from the documentation fails mysteriously: https://www.php.net/manual/en/ffi.examples-complete.php The fix is simple enough: set opcache.enable_cli to true. It took me and another person in IRC over an hour to notice that, however. Let's not make anyone else go through that. :-) I am not sure if there's something to be done about it other than adding the opcache.enable_cli line to the example linked above and documenting why it's needed. The defaults all make sense in themselves, but the result is broken in some circumstances. There may be other things that should be done as well; I'm not sure. I defer to the list on how best to proceed here. Addendum: The documentation for ffi.preload is completely unhelpful. I have no idea what file to put there or what it does. Can someone who understands that help improve the docs on it? -- Larry Garfield larry@garfieldtech.com