Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61264 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11123 invoked from network); 16 Jul 2012 00:15:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2012 00:15:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.173 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.173 smtp173.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.173] ([67.192.241.173:57621] helo=smtp173.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EB/A2-20866-B3D53005 for ; Sun, 15 Jul 2012 20:15:55 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp7.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id C9F162583E7; Sun, 15 Jul 2012 20:15:52 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp7.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 5E9892583E4; Sun, 15 Jul 2012 20:15:52 -0400 (EDT) Message-ID: <50035D2A.7050906@sugarcrm.com> Date: Sun, 15 Jul 2012 17:15:38 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Stefan Esser CC: Mailing-List php References: <5262BA67-53D2-4D19-9AD6-B1BFDABAC32E@sektioneins.de> In-Reply-To: <5262BA67-53D2-4D19-9AD6-B1BFDABAC32E@sektioneins.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] zend_execute_internal hook missing from PHP 5 From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > Nowadays (since PHP 5.0) the code was moved from > call_user_function_ex to zend_call_function and just looks like > this: > > ((zend_internal_function *) > EX(function_state).function)->handler(fci->param_count, > *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 > TSRMLS_CC); > > > While this has no immediate impact for average PHP users, it > basically kills the possibility for an extension like Suhosin to > catch all function starts. This should also be a problem for your > DTRACE support. And IIRC Xdebug was hooking this point (at least in > the past), too. > > My suggestion is to change the code to call the hook again. There's a bit of a problem there. The problem is that execute_internal looks like this: zval **return_value_ptr = &(*(temp_variable *)((char *) execute_data_ptr->Ts + execute_data_ptr->opline->result.var)).var.ptr; ((zend_internal_function *) execute_data_ptr->function_state.function)->handler(execute_data_ptr->opline->extended_value, *return_value_ptr, (execute_data_ptr->function_state.function->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)?return_value_ptr:NULL, execute_data_ptr->object, return_value_used TSRMLS_CC); You note it takes return values from opline. Which is fine when running PHP code, but when running internal function from internal function, there's no opline. So zend_call_function calls this: ((zend_internal_function *) EX(function_state).function)->handler(fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC); I.e. it uses data from fci. But if we use zend_execute_internal we have only execute_data_ptr to work with, which has wrong return values. So we need to either make fake opline somehow or find a way to pass correct return vars to the handler via execute_internal. I'll see how it can be done but that'd be probably in 5.5 since it may require some engine changes, which is not an option for stable versions. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227