Re: PHP Embedded
| From: | Mark Evans | Date: | Thu, 16 Mar 2006 12:34:09 +0000 |
| Subject: | Re: PHP Embedded | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-22482@lists.php.net to get a copy of this message | ||
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<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<char> > > & sCode={...}, _zval_struct * pzvalResult=0x0012e558, bool bExpression=false) Line 372 + 0x7c C++Any advice is greatly appreciated. Regards Mark