c - How can I debug 'zend_mm_heap corrupted' for my php extension -



c - How can I debug 'zend_mm_heap corrupted' for my php extension -

the problem

i've written php extension (php 5.3) appears work fine simple tests moment start making multiple calls start seeing error:

zend_mm_heap corrupted

normally through console or apache error log, see error

[thu jun 19 16:12:31.934289 2014] [:error] [pid 560] [client 127.0.0.1:35410] php fatal error: allowed memory size of 134217728 bytes exhausted (tried allocate 139678164955264 bytes) in unknown on line 0

what i've tried do

i've tried find exact spot issue occurs appears occurs between destructor beingness called php class calls extension before constructor runs first line of constructor (note, have used phpunit diagnose this, if run in browser work 1 time , throw error log on next effort 'the connection reset' in browser window no output.

i've tried adding debug lines memory_get_usage , installing extension memprof output fails show serious memory issues , i've never seen memory usage greater 8mb.

i've looked @ other stack overflow posts regard changing php settings deal zend_mm_corrupted issue, disabling/enabling garbage collection without grade of success.

what i'm looking for

i realise there not plenty info here perchance know causing presume memory leak, want know possible , probable causes of issue , how can go diagnosing issue find problem is.

note:

i have tried building extension --enable-debug comes unrecognised argument.

edit: valgrind

i have run on valgrind , got next output:

--24803-- redir: 0x4ebde30 (__gi_strncmp) redirected 0x4c2dd20 (__gi_strncmp) --24803-- redir: 0x4ec1820 (__gi_stpcpy) redirected 0x4c2f860 (__gi_stpcpy) segmentation fault (core dumped) ==24803== ==24803== heap summary: ==24803== in utilize @ exit: 2,401 bytes in 72 blocks ==24803== total heap usage: 73 allocs, 1 frees, 2,417 bytes allocated ==24803== ==24803== searching pointers 72 not-freed blocks ==24803== checked 92,624 bytes ==24803== ==24803== leak summary: ==24803== lost: 0 bytes in 0 blocks ==24803== indirectly lost: 0 bytes in 0 blocks ==24803== perchance lost: 0 bytes in 0 blocks ==24803== still reachable: 2,401 bytes in 72 blocks ==24803== suppressed: 0 bytes in 0 blocks ==24803== reachable blocks (those pointer found) not shown. ==24803== see them, rerun with: --leak-check=full --show-reachable=yes ==24803== ==24803== error summary: 0 errors 0 contexts (suppressed: 2 2) --24803-- --24803-- used_suppression: 2 dl-hack3-cond-1 ==24803== ==24803== error summary: 0 errors 0 contexts (suppressed: 2 2)

this suggests me perhaps issue isn't memory leak not on this.

it appears me programme have heap memory corruption. is bit hard find looking out code snippet or faulty phone call stack. may want run programme under dynamic tools(valgrind, winddbg/pageheap) track actual source of error.

$ valgrind --tool=memcheck --db-attach=yes ./a.out

this way valgrind attach programme in debugger when first memory error detected can live debugging(gdb). should best possible way understand , resolve problem.

allowed memory size of 134217728 bytes exhausted (tried allocate 139678164955264 bytes) in unknown on line 0

it looks somewhere in programme signed unsigned conversion getting executed. allocators have size parameter of unsigned type interpret negative value big type , under scenario, allocation fail.

c memory-management memory-leaks php-extension

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -