Hi,

I have recently seen httpd core dump on my system.  After looking into this 
issue it is the php module which is actually core dumping more specifically the 
zend memory management part of php.

#0  0x0115d224 in zend_mm_remove_from_free_list (heap=0x99596e8,
    p=<value optimized out>)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_alloc.c:837

The following line is failing in zend_mm_remove_from_fee_list which is in 
zend_alloc.c

#if ZEND_MM_SAFE_UNLINKING
        if (UNEXPECTED(prev->next_free_block != mm_block) || 
UNEXPECTED(next->prev_free_block != mm_block)) {
            zend_mm_panic("zend_mm_heap corrupted");
        }
#endif

The core file tells me that next pointer is null so this is crashing when 
trying to dereference a null pointer.  My first question is next ever expected 
to be null?  After looking through the code, it seems that if there is only one 
element in the list that next & prev will be both equal to mm_block, is this a 
true assumption?

I am not sure what has gotten my system into this state the only hints I have 
is that there were a fair amount of objects created and an init 6 was sent and 
during the shut down of the php module this issue was seen.

I have done some investigation into this issue and came across a fairly long 
bug report https://bugs.php.net/bug.php?id=40479.  However I am not sure if 
this is the same issue since I never see the "zend_mm_heap corrupted" message 
since the code fails due to the null pointer dereference before outputting this 
error message however this may be related in the fact that my heap is being 
corrupted.

Since I do not have a solid reproducer or know why my heap is in this state.  I 
was wondering if I could get some information to help me debug this.  Do you 
have any hunches on what could be setting next to null?  What does it mean when 
next is null is this because the list is at the end or is this a dangling 
pointer and next should never be null?  Do you have any hints on a possible 
reproducer using just php which would put me into the state where next is null? 
 Also during my research on similar issues I have read that cache may have a 
role in causing the heap to be corrupted.  How could the cache be corrupting 
the heap? Is that possible?

My current version of php is:
PHP 5.2.17 (cli) (built: Aug  2 2011 13:33:29)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans

I am running centos 5.6 and this issue has been seen on both 32 bit and 64 bit.


Also this issue has been seen only after upgrading from php 5.2.6 to 5.2.17.  
Do you know of a change made between these releases that could have an affect 
on the memory management?

Thread 1 (Thread 30656):
#0  0x0115d224 in zend_mm_remove_from_free_list (heap=0x99596e8,
    p=<value optimized out>)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_alloc.c:837
#1  _zend_mm_free_int (heap=0x99596e8, p=<value optimized out>)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_alloc.c:1979
#2  0x0117965a in _zval_dtor_func (zvalue=0x9a2e300)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_variables.c:43
#3  0x0116c388 in _zval_dtor (zval_ptr=0x9d60ae0)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_variables.h:35
#4  _zval_ptr_dtor (zval_ptr=0x9d60ae0)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_execute_API.c:414
#5  0x01184d77 in zend_hash_destroy (ht=0x9d5ecfc)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_hash.c:526
#6  0x0117050d in destroy_zend_class (pce=0x9eaf7b4)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_opcode.c:185
#7  0x01184d77 in zend_hash_destroy (ht=0x99599b0)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_hash.c:526
#8  0x0117a09e in zend_shutdown ()
    at /scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend.c:736
#9  0x01131f35 in php_module_shutdown ()
    at /scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/main/main.c:1918
#10 0x01131ff7 in php_module_shutdown_wrapper (sapi_globals=0x12849e0)
    at /scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/main/main.c:1889
#11 0x01202211 in php_apache_child_shutdown (tmp=0x0)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/sapi/apache2handler/sapi_apache2.c:369
#12 0x00cdbe8d in ?? () from /usr/lib/libapr-1.so.0
#13 0x00cdc63d in apr_pool_destroy () from /usr/lib/libapr-1.so.0
#14 0x003909e5 in ?? ()
#15 0x00390a0d in ?? ()
#16 <signal handler called>
#17 zend_hash_destroy (ht=0xa42b9a8)
    at 
/scratchpad/workdirs/ssilva/build/RPM/BUILD/php-5.2.17/Zend/zend_hash.c:522

Thanks,
Alan

Reply via email to