Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102079 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54794 invoked from network); 26 Apr 2018 18:47:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Apr 2018 18:47:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 104.47.36.100 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 104.47.36.100 mail-sn1nam02on0100.outbound.protection.outlook.com Received: from [104.47.36.100] ([104.47.36.100:24086] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/25-19179-7DE12EA5 for ; Thu, 26 Apr 2018 14:47:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1ye24l8fvtqDsftSPf6yTyOpCK9THqHCuhWK6XuG65c=; b=rjfl9LrqRGD0S7bc8tuJgpjwGd9xCzef4DVAYk/T1y4n2EMXrLc4eKSU5R0r45szw378Xoc5znjBoeSkzUyEzIbBDPRdrml5CV8TGnWiBA3HLrIUNGRnOG+F5hCEWCT7fQd3j0+58dbB76KzM4MRoZ0V0K1OxQewJeE+vN0g50k= Received: from BN6PR02MB3234.namprd02.prod.outlook.com (10.161.152.32) by BN6PR02MB2354.namprd02.prod.outlook.com (10.168.254.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.715.18; Thu, 26 Apr 2018 18:47:46 +0000 Received: from BN6PR02MB3234.namprd02.prod.outlook.com ([fe80::b5e1:42c:d6ad:56c]) by BN6PR02MB3234.namprd02.prod.outlook.com ([fe80::b5e1:42c:d6ad:56c%13]) with mapi id 15.20.0715.018; Thu, 26 Apr 2018 18:47:45 +0000 To: Michael Wallner CC: Stanislav Malyshev , Zeev Suraski , Xinchen Hui , Nikita Popov , Bob Weinand , "Anatol Belski (ab@php.net)" , "PHP internals list" Thread-Topic: [PHP-DEV] PHP FFI extenesion Thread-Index: AQHT0yrBnLpXxgz1HEWdw/jxKSLJkaQEFM4AgABk3QCAABugkIAOJYwAgAAf5oOAAJf2BQ== Date: Thu, 26 Apr 2018 18:47:45 +0000 Message-ID: References: <56794c33-a728-d399-2462-b62ba1b7a509@gmail.com> ,<739e66c6-e60b-005e-acb0-d5c4fb2da11d@php.net>,<6760eb1f-4345-48d2-a5c2-727cd98e3ac2@email.android.com> In-Reply-To: <6760eb1f-4345-48d2-a5c2-727cd98e3ac2@email.android.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmitry@zend.com; x-originating-ip: [212.232.72.197] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BN6PR02MB2354;7:fJyH+oRAh/Kr7KA9dGILHmfANNEAOlHrsZRg2EHl4UiJlDEsdBYh0LEOYm6jlZpEhVZxQNj8uyNOtxTVhhcVsD8ExBPf8uqEcQZ8hnDQ+oNXXFPbFV4mAix7qul5sNT3njjychr+lxI99t5Huh/H4g4OtR9i+KU5Xk/hBOO7QNvnzc1AWBu6d49deTqPwcT7cQgPsxI4wc90bizJ5wbO6zfZuyXQkiMQ4ZDMuvoyfVpXHNg9oUSAgsSLU+Y3nHGy x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10019020)(366004)(396003)(39850400004)(346002)(39380400002)(376002)(189003)(199004)(76176011)(25786009)(6246003)(66066001)(97736004)(4326008)(6436002)(7696005)(86362001)(486006)(2900100001)(476003)(11346002)(5250100002)(7736002)(74316002)(446003)(99286004)(3846002)(6116002)(575784001)(14454004)(19627405001)(81166006)(81156014)(54906003)(53936002)(8936002)(93886005)(5660300001)(33656002)(316002)(8676002)(2906002)(3280700002)(68736007)(54896002)(6506007)(26005)(39060400002)(53546011)(59450400001)(102836004)(9686003)(3660700001)(478600001)(6916009)(55016002)(186003)(105586002)(6606003)(229853002)(106356001)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR02MB2354;H:BN6PR02MB3234.namprd02.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:BN6PR02MB2354; x-ms-traffictypediagnostic: BN6PR02MB2354: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(192374486261705); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231232)(944501410)(52105095)(3002001)(10201501046)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011);SRVR:BN6PR02MB2354;BCL:0;PCL:0;RULEID:;SRVR:BN6PR02MB2354; x-forefront-prvs: 0654257CF5 received-spf: None (protection.outlook.com: zend.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: BLmkvRPocftlT8LKTcyi4KpN91XJK0dSS5a/ckmDA/7xDusYdRL+0X4tFeMMpKd93YDUShfeJeIB0mineJkhMTAiH8HhV0PLu+LAXPz5rBDKsfXlqWXPb1R+Y2gaoPScGxqGL6vY22ofcbcb3vNU2MQSB9yX1Ou4puHjh4bobpPd0coQgE7NCjgvyh4lJW1J spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_BN6PR02MB3234AD5393026DAFE1960EF2BF8E0BN6PR02MB3234namp_" MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: fe9ba46a-4ca0-4cb1-cee4-08d5aba63320 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe9ba46a-4ca0-4cb1-cee4-08d5aba63320 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Apr 2018 18:47:45.1470 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB2354 Subject: Re: [PHP-DEV] PHP FFI extenesion From: dmitry@zend.com (Dmitry Stogov) --_000_BN6PR02MB3234AD5393026DAFE1960EF2BF8E0BN6PR02MB3234namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Michael, I've just tried to run PSI with php-master (32-bit DEBUG build) and got SIG= SEGV on the simplest test. Use "psi.d/string.psi" and attemt to call psi\strerror(10) #0 0xf44916ba in psi_call_frame_parse_args (frame=3D0xf426c500, execute_da= ta=3D0x0) at /home/dmitry/php/ext-psi/src/call.c:273 #1 0xf4494fe7 in psi_context_call (C=3D0x92dfe90, execute_data=3D0x0, retu= rn_value=3D0x8fc0144 , impl=3D0x9341658) at /home/dmitry/php/ext-psi/src/context.c:250 #2 0xf4499b44 in psi_ffi_handler (sig=3D0x92e0fa0, result=3D0xffff9760, ar= gs=3D0xffff96f0, data=3D0x9341658) at /home/dmitry/php/ext-psi/src/libffi.c:387 #3 0xf4467a76 in ffi_closure_SYSV_inner () from /lib/libffi.so.6 #4 0xf4467eb6 in ffi_closure_SYSV () from /lib/libffi.so.6 #5 0x08701d21 in ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER () at /hom= e/dmitry/php/php-master/Zend/zend_vm_execute.h:890 #6 0x0875fd12 in execute_ex (ex=3D0xf421d020) at /home/dmitry/php/php-mast= er/Zend/zend_vm_execute.h:54819 #7 0x087643b1 in zend_execute (op_array=3D0xf426c460, return_value=3D0x0) = at /home/dmitry/php/php-master/Zend/zend_vm_execute.h:59987 #8 0x086b0d2f in zend_execute_scripts (type=3D8, retval=3D0x0, file_count= =3D3) at /home/dmitry/php/php-master/Zend/zend.c:1566 #9 0x0863cdde in php_execute_script (primary_file=3D0xffffcbbc) at /home/d= mitry/php/php-master/main/main.c:2467 #10 0x0876676a in do_cli (argc=3D2, argv=3D0x90e4850) at /home/dmitry/php/p= hp-master/sapi/cli/php_cli.c:1011 #11 0x087673b2 in main (argc=3D2, argv=3D0x90e4850) at /home/dmitry/php/php= -master/sapi/cli/php_cli.c:1404 execute_data is NULL Did you test ext-psi with php-master? As I understood, you create libffi callback/closure for each function decla= red in *.psi file(s). And then use it to call a general psi_ffi_handler(). Why not to call a general function handler in first place (without any ffi = magic)? Thanks. Dmitry. ________________________________ From: Dmitry Stogov Sent: Thursday, April 26, 2018 12:25:37 PM To: Michael Wallner Cc: Dmitry Stogov; Stanislav Malyshev; Zeev Suraski; Xinchen Hui; Nikita Po= pov; Bob Weinand; Anatol Belski (ab@php.net); PHP internals list Subject: Re: [PHP-DEV] PHP FFI extenesion hi Michael, On Apr 26, 2018 10:31 AM, Michael Wallner wrote: Hey Dmitry! On 17/04/18 09:29, Dmitry Stogov wrote: > hi Michael, > > it's pitty, I didn't found this extension before. > thanks for pointing, I'll definetly take a look. Did you have a chance to look at it yet? Yeah. I took a look through API and implementation, but didn't try to use i= t in action. I exited by the amount of work you did, and see advantages in your approach= , but in general, I like to provide a bit different thing. Acttually, my FFI extension inspired by LuaJit implementation (copied by Py= thon cffi ABI mode). I prefer exteremely simple API, simple and compact implementation. I especi= ally, selected run-time binding, because plan to integrate FFI with JIT (ma= in advantage of LuaJit). [see below] > I, also, like the idea of preloading ffi definitions on startup, but I > would prefer to allow preloading any php files. Especially for FFI, PHP > wrappers would able to hide dangerous implementation details. > I'm not sure the one depends on the other, and how would that be different to opcache? With PSI everything related C is encapsulated, you cannot change anything regarding the access or calling scheme at runtime. I admit, PSI is far away from being optimized or even finished yet, but there are a few important key differentiation points: - the system administrator controls FFI - parses C headers, no need to duplicate declarations - function call and data access is pre-defined, not at runtime Yeah. I see these differences. Reuse of system headers is definitely a big = advantage. Pre-loading and absence of run-time definition, is good from security poin = of view, but makes usage a bit more complex. The thing, I don't like, is a = special binding language. Most probably, both FFI and PSI might be better, taking ideas from the othe= r... Did you use PSI with some complex libraries? Thanks. Dmitry. -- Regards, Mike Hey Dmitry! On 17/04/18 09:29, Dmitry Stogov wrote: > hi Michael, > > it's pitty, I didn't found this extension before. > thanks for pointing, I'll definetly take a look. Did you have a chance to look at it yet? > I, also, like the idea of preloading ffi definitions on startup, but I > would prefer to allow preloading any php files. Especially for FFI, PHP > wrappers would able to hide dangerous implementation details. > I'm not sure the one depends on the other, and how would that be different to opcache? With PSI everything related C is encapsulated, you cannot change anything regarding the access or calling scheme at runtime. I admit, PSI is far away from being optimized or even finished yet, but there are a few important key differentiation points: - the system administrator controls FFI - parses C headers, no need to duplicate declarations - function call and data access is pre-defined, not at runtime -- Regards, Mike --_000_BN6PR02MB3234AD5393026DAFE1960EF2BF8E0BN6PR02MB3234namp_--