Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22482 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11517 invoked by uid 1010); 16 Mar 2006 12:34:09 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 11502 invoked from network); 16 Mar 2006 12:34:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2006 12:34:09 -0000 X-Host-Fingerprint: 80.35.80.143 143.Red-80-35-80.staticIP.rima-tde.net Received: from ([80.35.80.143:4144] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 48/16-55982-14B59144 for ; Thu, 16 Mar 2006 07:34:09 -0500 Message-ID: <48.16.55982.14B59144@pb1.pair.com> To: internals@lists.php.net Date: Thu, 16 Mar 2006 13:34:09 +0100 User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 References: <2fd662a00603141148n1f3c6aw@mail.gmail.com> <200603142158.25640.johannes@php.net> In-Reply-To: <200603142158.25640.johannes@php.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 80.35.80.143 Subject: Re: [PHP-DEV] PHP Embedded From: markright@gmail.com (Mark Evans) Hi All I am back again :-) > Here one can't say much without any details (_relevant_ code and > backtrace) The c++ guys are still having some problems and they have given me some more info.. The app is init'd using the following __declspec(dllexport) void InitPHPEngine(const CString& sStartupDir) { static bool bInitialised = false; if (!bInitialised) { int argc = 1; char *argv[2] = {"Actinic", NULL}; php_embed_module.ub_write = ub_write; // output is redirected to our callback function php_embed_module.log_message = log_message; php_embed_module.sapi_error = sapi_error; php_embed_module.php_ini_path_override = ".\\"; php_embed_init(argc, argv PTSRMLS_CC); // init the engine CString sInit = PHP_INIT_SCRIPT; if (!sStartupDir.IsEmpty()) // if startup dir is defined { CString sPath; sPath.Format("chdir(\"%s\");", CTextUtils::MakeStringSafeForQuotedPerlFragment(sStartupDir)); sInit += sPath; } zend_eval_string(sInit.GetBuffer(), NULL, "main" TSRMLS_CC); bInitialised = true; } } They then have a method BOOL PHPEvalString(const CString& sCode, zval *pzvalResult, bool bExpression) { CString sPreparedCode; if (bExpression) // we should apply a trick for expressions { sPreparedCode.Format(_T("%s ? true : false"), sCode); } else { sPreparedCode = sCode; gsPhpOutput.Empty(); gsPhpOutput.GetBuffer(sCode.GetLength()); // preallocate the string - hopefully the result has similar length as the original script, so probably that's a good guess gsPhpOutput.ReleaseBuffer(); // doesn't release the extra bytes } char* pcScript = sPreparedCode.GetBuffer(sPreparedCode.GetLength()); zend_first_try { PG(during_request_startup) = 0; int nResult; if (bExpression) { nResult = zend_eval_string(pcScript, pzvalResult, "main" TSRMLS_CC); } else { nResult = zend_eval_string(pcScript, NULL, "main" TSRMLS_CC); } if (nResult == FAILURE) { return FALSE; } } zend_catch { return FALSE; } zend_end_try(); return TRUE; } Therefore they want to shut down the request after the line nResult = zend_eval_string(pcScript, NULL, "main" TSRMLS_CC); and restart it for the next call But doing nResult = zend_eval_string(pcScript, NULL, "main" TSRMLS_CC); TSRMLS_FETCH(); php_request_shutdown(NULL); php_request_startup(TSRMLS_C); Causes an immediate crash when it reaches php_request_startup(TSRMLS_C); :( Also because init, eval and shutdown are in separate functions tsrm_ls is defined as static in the app. The also sent me the following backtrace if its of any use.. php4ts.dll!00d45b61() php4ts.dll!00d45622() user32.dll!77d6ebe2() php4ts.dll!00d43e16() > ActPHPRunner.dll!PHPEvalString(const ATL::CStringT > > & sCode={...}, _zval_struct * pzvalResult=0x0012e558, bool bExpression=false) Line 372 + 0x7c C++ Any advice is greatly appreciated. Regards Mark