Is it safe to write PHP extensions in C++?
I read on Sara Golemon's book that the zend engine can bailout on a request 
during a call to php_error_docref() or even an emaloc() that exceeds the 
allowed memory,  doing an immediate longjmp() to the shutdown part of the 
engine.
longjmp() does not work well with C++ destructors.
For example:
[code]
void some_function( TSRMLS_D )
{
 Someclass obj( 3 );
 char *dst = emalloc(Morethanscriptlimit);
 ...
 
void some_function( TSRMLS_D )
{
 Someclass obj( 3 ); 
 php_error_docref( NULL TSRMLS_CC, E_ERROR, "Some error" );
 ...
[/code]
in these two cases ~Someclass() may never be invoked on obj, if either 
php_error_docref() or emalloc calls longjmp().

Reply via email to