PHP Debugging Your Set-Up PHP NorthWest 2017 Manchester, UK 51.150564.43284 January 27th, 2017 Derick Rethans derick@mongodb.com derickr https://joind.in/22137 slides/mongodb/title.xml slides/mongodb/me.xml In this session we will look at low-level (Linux) system debugging tools to find out what is going on (or wrong!) with your PHP environment, although the techniques are also valid for other programs besides PHP. We will cover debugging crashes with gdb, checking out memory leaks with valgrind, and many other tools to find out what is going wrong, and hopefully, figure out why. This session teaches tools to help out with tracking down bugs, and provides information on how to get better at debugging connection issues, crashes, files not being written, etc. The session is also valuable for people who want to help out with providing good bug reports for Open Source projects. slides/debugging/storytime.xml - don't jump to conclusions - unless you know what you're doing ;-) https://jira.mongodb.org/browse/PHPC-894 / https://github.com/mongodb/mongo-php-driver/issues/514 slides/debugging/jump-conclusions.xml slides/debugging/jump-memory-leak.xml slides/debugging/toolbox.xml slides/debugging/toolbox-items.xml slides/debugging/section-strace.xml slides/debugging/strace-systemcalls.xml slides/debugging/strace-invocation.xml slides/debugging/strace-invocation-phpini.xml slides/debugging/strace-invocation-socket.xml slides/debugging/demo.xml - strace - what is it? - how does it work? - php.ini loading slides/debugging/jump-conclusions.xml slides/debugging/section-lsof.xml slides/debugging/lsof-files-unix.xml slides/debugging/lsof-invocation.xml slides/debugging/demo.xml slides/debugging/lsof-invocation-cant-listen.xml - lsof -i - what is it? - how does it work? - socket with xdebug and fork - set size: https://youtrack.jetbrains.com/issue/WI-31522, "PHP Scripts with Background Child Process" email - setsize - small test case - https://github.com/sebastianbergmann/php-code-coverage/issues/488 slides/debugging/section-gdb.xml slides/debugging/gdb-what-is-it.xml slides/debugging/gdb-backtrace.xml slides/debugging/gdb-symbols.xml slides/debugging/demo.xml slides/debugging/gdb-optimisation.xml slides/debugging/gdb-optimisation-asm.xml slides/debugging/gdb-optimisation-wrong.xml slides/debugging/gdb-short-case.xml slides/debugging/gdb-usage.xml slides/debugging/gdb-debug-core.xml slides/debugging/gdb-attach.xml slides/debugging/demo.xml slides/debugging/gdb-zbacktrace.xml - gdb - what is it? - how does it work? - talk about memory management in PHP - crashes - core files - - attach to running PID - run from within - httpd -X - symbols included - optimisation - zbacktrace slides/debugging/section-valgrind.xml slides/debugging/valgrind-how.xml slides/debugging/jump-memory-leak.xml slides/debugging/valgrind-show-leak1.xml slides/debugging/valgrind-show-leak2.xml slides/debugging/valgrind-show-leak3.xml slides/debugging/valgrind-show-leak4.xml slides/debugging/valgrind-show-leak5.xml slides/debugging/valgrind-show-leak6.xml slides/debugging/valgrind-wrap-up.xml - valgrind - what is it? - how does it work? - memory leaks - get_properties/get_gc - run from with in - use with gdb - USE_ZEND_ALLOC=0 - ZEND_DONT_UNLOAD_MODULES ** OPTIMISATION GONE WRONG ** - gcc -S - what is it? - how does it work? - compiler bug with alloca: https://bugs.xdebug.org/view.php?id=1337 https://bugs.php.net/bug.php?id=73545, - don't use xdebug (sigh) - https://github.com/xdebug/xdebug/commit/c36ea38141cb9403ff4bf72602fcf4ae62e5ba1e - https://bugs.php.net/bug.php?id=73545 slides/debugging/toolbox-items.xml slides/mongodb/questions.xml slides/mongodb/resources.xml