Hi, Richard

I'm afraid the below patch couldn't resolve my php crash issue.
However I do find some interesting stuff.

1. php5.2.11 + below patch, php5.2 svn branch + below patch, original php5.2.11
    php were compiled with
CC="gcc" CFLAGS="-O3 -fPIC" ./configure
--with-mysql=/usr/local/mysql
--with-gettext --with-zlib --with-nsapi=/home/sun/webserver7/
--enable-force-cgi-redirect --with-pdo-mysql=/user/local/mysql
--with-curl --with-gd=/home/apache_webserver/gd-2.0.35
--with-jpeg-dir=/home/apache_webserver/jpeg-6b
*note that: no --enable-debug flag.
    All got crash with segment fault at _zend_mm_free_int

2. I wanted to get more stack info, so I compiled original php5.2.11
with --enable-debug flag. When testing Olio with lower users, every
thing is fine, no crash. However when testing Olio with higher users,
SWS crash again. This time got segment fault at _efree_ts which was
similar like the core stack in
http://hg.genunix.org/php-experiment.hg/rev/73022b24276d

3. So I compiled php5.2.11 + patch with --enable-debug again, now no
crash even with higher users.

So the patch can resolve the crash at _efree_ts, however not at
_zend_mm_free_int. I suspected --enable-debug will slower php
execution that decrease the possiblity of crash at _zend_mm_free_int.
However I think --enable-debug is not a good solution, PHP has another
crash issue with PDO related.

Could you please forward these info to your colleage or php guys?

Thx, Xuekun

On Wed, Oct 21, 2009 at 7:43 AM, Richard Smith <[email protected]> wrote:
> Hi Xuekun,
>
> Basant has now submitted Bug #49937 Race condition in PDOStatement,
> and the patch it references is also attached.
> http://bugs.php.net/bug.php?id=49937&thanks=1
>
> Richard.
>
> --
> ============================================================================
>  ,-_|\   Richard Smith Staff Engineer PAE
>  /     \  Sun Microsystems                   Phone : +61 3 9869 6200
> [email protected]                        Direct : +61 3 9869 6224
>  \_,-._/  476 St Kilda Road                    Fax : +61 3 9869 6290
>      v   Melbourne Vic 3004 Australia
> ===========================================================================
>
> Index: ext/pdo/pdo_stmt.c
> ===================================================================
> --- ext/pdo/pdo_stmt.c  (revision 289806)
> +++ ext/pdo/pdo_stmt.c  (working copy)
> @@ -2325,7 +2325,7 @@
>        stmt->refcount = 1;
>        ALLOC_HASHTABLE(stmt->properties);
>        zend_hash_init(stmt->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
> -       zend_hash_copy(stmt->properties, &stmt->ce->default_properties,
> (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
> +       zend_hash_copy(stmt->properties, &stmt->ce->default_properties,
> (copy_ctor_func_t) zval_add_ref_atomic, (void *) &tmp, sizeof(zval *));
>
>        old_stmt = (pdo_stmt_t *)zend_object_store_get_object(zobject
> TSRMLS_CC);
>
> @@ -2454,7 +2454,7 @@
>        stmt->refcount = 1;
>        ALLOC_HASHTABLE(stmt->properties);
>        zend_hash_init(stmt->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
> -       zend_hash_copy(stmt->properties, &ce->default_properties,
> (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
> +       zend_hash_copy(stmt->properties, &ce->default_properties,
> (copy_ctor_func_t) zval_add_ref_atomic, (void *) &tmp, sizeof(zval *));
>
>        retval.handle = zend_objects_store_put(stmt,
> (zend_objects_store_dtor_t)zend_objects_destroy_object,
> (zend_objects_free_object_storage_t)pdo_dbstmt_free_storage,
> (zend_objects_store_clone_t)dbstmt_clone_obj TSRMLS_CC);
>        retval.handlers = &pdo_dbstmt_object_handlers;
> Index: TSRM/TSRM.c
> ===================================================================
> --- TSRM/TSRM.c (revision 289806)
> +++ TSRM/TSRM.c (working copy)
> @@ -714,6 +714,12 @@
>        return retval;
>  }
>
> +TSRM_API void *tsrm_atomic_incr(volatile unsigned int* val)
> +{
> +       tsrm_mutex_lock(tsmm_mutex);
> +       ++*val;
> +       tsrm_mutex_unlock(tsmm_mutex);
> +}
>
>
>  /*
> Index: TSRM/TSRM.h
> ===================================================================
> --- TSRM/TSRM.h (revision 289806)
> +++ TSRM/TSRM.h (working copy)
> @@ -139,6 +139,7 @@
>
>  TSRM_API void *tsrm_set_new_thread_begin_handler(tsrm_thread_begin_func_t
> new_thread_begin_handler);
>  TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t
> new_thread_end_handler);
> +TSRM_API void *tsrm_atomic_incr(volatile unsigned int* val);
>
>  /* these 3 APIs should only be used by people that fully understand the
> threading model
>  * used by PHP/Zend and the selected SAPI. */
> Index: Zend/zend_variables.c
> ===================================================================
> --- Zend/zend_variables.c       (revision 289806)
> +++ Zend/zend_variables.c       (working copy)
> @@ -100,6 +100,17 @@
>  }
>  /* }}} */
>
> +
> +ZEND_API void zval_add_ref_atomic(zval **p) /* {{{ */
> +{
> +#ifdef ZTS
> +       tsrm_atomic_incr(&(*p)->refcount);
> +#else
> +       (*p)->refcount++;
> +#endif
> +}
> +/* }}} */
> +
>  ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC) /* {{{
> */
>  {
>        switch (zvalue->type) {
> Index: Zend/zend_variables.h
> ===================================================================
> --- Zend/zend_variables.h       (revision 289806)
> +++ Zend/zend_variables.h       (working copy)
> @@ -76,6 +76,7 @@
>  #endif
>
>  ZEND_API void zval_add_ref(zval **p);
> +ZEND_API void zval_add_ref_atomic(zval **p);
>
>  END_EXTERN_C()
>
>
>

Reply via email to