adsr / phpspy

low-overhead sampling profiler for PHP 7+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docker: not displaying anything when profiling a PHP script

ahocquard opened this issue · comments

Hello,

I can't profile a php script inside docker. It is pending and it displays nothing.
I can strace the PHP script without any problem.

docker run --privileged --cap-add=SYS_PTRACE --rm akeneo/php php -r "sleep(100);"

I execute phpspy with strace to better know what happens:

sudo strace ./phpspy -p 20493

And here is what I get:

...
clock_gettime(CLOCK_MONOTONIC_RAW, {tv_sec=117355, tv_nsec=921478423}) = 0
process_vm_readv(20493, [{iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=496}], 1, [{iov_base=0x5562e9485940, iov_len=496}], 1, 0) = 496
clock_gettime(CLOCK_MONOTONIC_RAW, {tv_sec=117355, tv_nsec=921772631}) = 0
nanosleep({tv_sec=0, tv_nsec=9806802}, NULL) = 0
clock_gettime(CLOCK_MONOTONIC_RAW, {tv_sec=117355, tv_nsec=931932920}) = 0
process_vm_readv(20493, [{iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=496}], 1, [{iov_base=0x5562e9485940, iov_len=496}], 1, 0) = 496
clock_gettime(CLOCK_MONOTONIC_RAW, {tv_sec=117355, tv_nsec=932174327}) = 0
nanosleep({tv_sec=0, tv_nsec=9859603}, NULL) = 0
clock_gettime(CLOCK_MONOTONIC_RAW, {tv_sec=117355, tv_nsec=942321317}) = 0
process_vm_readv(20493, [{iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=496}], 1, [{iov_base=0x5562e9485940, iov_len=496}], 1, 0) = 496
clock_gettime(CLOCK_MONOTONIC_RAW, {tv_sec=117355, tv_nsec=942508791}) = 0
nanosleep({tv_sec=0, tv_nsec=9913536}, NULL) = 0
...

Also, I tried with the official PHP image:
docker run --privileged --cap-add=SYS_PTRACE --rm php php -r "sleep(100);"

but I got another error, which is not related to this issue I suppose.

popen_read_line: No stdout; cmd=awk '/libphp7/{print $NF; exit 0} END{exit 1}' /proc/21207/maps || readlink -e /proc/21207/exe
get_php_bin_path: Failed

Am I missing something?

Thanks.

commented

Thanks for the report. fa16e94 should fix your issue. Please re-open if not. Thanks again.

adam@asx1c5:~$ docker run --privileged --cap-add=SYS_PTRACE --rm php php -r "sleep(300);" &
[1] 5468
adam@asx1c5:~$ pgrep -af sleep.*300
5468 docker run --privileged --cap-add=SYS_PTRACE --rm php php -r sleep(300);
5513 php -r sleep(300);
adam@asx1c5:~$ sudo ~/phpspy/phpspy -p 5513 -l 1
0 sleep <internal>:-1
1 <main> <internal>:-1

This is working!

Thank you very much for the fix and the reactivity 😃