如何弄清楚无效的地址是什么

时间:2011-08-24 14:05:56

标签: c memory-leaks valgrind

Valgrind报道:

==4538== Invalid read of size 4
==4538==    at 0x822D3C6: _zval_ptr_dtor (zend.h:385)
==4538==    by 0x823C1FF: _zval_ptr_dtor_wrapper (zend_variables.c:189)
==4538==    by 0x824E1A1: zend_hash_destroy (zend_hash.c:529)
==4538==    by 0x826655A: zend_object_std_dtor (zend_objects.c:45)
==4538==    by 0x8266A28: zend_objects_free_object_storage (zend_objects.c:126)
==4538==    by 0x826C43D: zend_objects_store_del_ref_by_handle_ex (zend_objects_API.c:220)
==4538==    by 0x826C0AC: zend_objects_store_del_ref (zend_objects_API.c:172)
==4538==    by 0x823BD77: _zval_dtor_func (zend_variables.c:52)
==4538==    by 0x822B99B: _zval_dtor (zend_variables.h:35)
==4538==    by 0x822D463: _zval_ptr_dtor (zend_execute_API.c:443)
==4538==    by 0x823C1FF: _zval_ptr_dtor_wrapper (zend_variables.c:189)
==4538==    by 0x824E518: zend_hash_apply_deleter (zend_hash.c:614)
==4538==  Address 0x44c1718 is 8 bytes inside a block of size 20 free'd
==4538==    at 0x4026E9C: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==4538==    by 0x8216374: _efree (zend_alloc.c:2358)
==4538==    by 0x822D48E: _zval_ptr_dtor (zend_execute_API.c:444)
==4538==    by 0x469B2C5: zim_ASTTree___destruct (parser.c:336)
==4538==    by 0x822F8CE: zend_call_function (zend_execute_API.c:986)
==4538==    by 0x825A8E2: zend_call_method (zend_interfaces.c:97)
==4538==    by 0x8266978: zend_objects_destroy_object (zend_objects.c:112)
==4538==    by 0x826C2AD: zend_objects_store_del_ref_by_handle_ex (zend_objects_API.c:206)
==4538==    by 0x826C0AC: zend_objects_store_del_ref (zend_objects_API.c:172)
==4538==    by 0x823BD77: _zval_dtor_func (zend_variables.c:52)
==4538==    by 0x822B99B: _zval_dtor (zend_variables.h:35)
==4538==    by 0x822D463: _zval_ptr_dtor (zend_execute_API.c:443)

如何找到无效读取的地址?

1 个答案:

答案 0 :(得分:2)

无效读取发生在名为zend_hash_destroy()的函数中。

但是早先已经通过zend_objects_destroy_object()函数释放了内存。

这一切都发生在“zend”内部这一事实似乎指出了“zend”的问题。如果您正在尝试调试PHP,我不确定您是否会在这里使用valgrind(尽管我喜欢这个工具)...