php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73484 phpdbg executes code incorrectly
Submitted: 2016-11-09 21:00 UTC Modified: 2016-11-14 14:39 UTC
From: deviantintegral at gmail dot com Assigned: bwoebi (profile)
Status: Not a bug Package: phpdbg
PHP Version: 7.1.0RC5 OS: Linux
Private report: No CVE-ID: None
 [2016-11-09 21:00 UTC] deviantintegral at gmail dot com
Description:
------------
I've been attempting to use phpdbg for code coverage reports with phpunit. I've had rather strange behaviour with it running Drupal 8's test suite. phpunit 4.8 tests simply stop running, with no error or segfault. I switched over to phpunit 5.4, so the warnings below can be ignored for now.

Under PHP 7, tests pass, but on further inspection, the assertions are not all being run correctly. For example, under php7:

Time: 14.94 seconds, Memory: 120.00Mb

OK (15 tests, 176 assertions

Under phpdbg:

Time: 5.31 seconds, Memory: 140.00Mb

OK (15 tests, 8 assertions)

This also affects PHP7.0, as I see similar behaviour there in the Ubuntu PPA for it: https://github.com/oerdnj/deb.sury.org/issues/485

Test script:
---------------
Here's a Dockerfile to replicate this bug against the latest RC:

FROM php:7.1-rc
RUN curl -OJ https://ftp.drupal.org/files/projects/drupal-8.2.2.tar.gz
RUN tar xzvf drupal-8.2.2.tar.gz
ENV SIMPLETEST_DB="sqlite://localhost//tmp/drupal.sqlite"
CMD cd drupal-8.2.2 \
  && php vendor/bin/phpunit --verbose --debug -c core/phpunit.xml.dist --group aggregator \
  && phpdbg -rrq vendor/bin/phpunit --verbose --debug -c core/phpunit.xml.dist --group aggregator

Build it with docker build, and then use docker run <image id> and note that the assertion counts are different.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-13 06:57 UTC] krakjoe@php.net
-Assigned To: +Assigned To: bwoebi
 [2016-11-13 16:30 UTC] bwoebi@php.net
-Status: Assigned +Status: Not a bug
 [2016-11-13 16:30 UTC] bwoebi@php.net
This is not a PHP bug.

This is phpunit reading from php://input (which is used for e.g. POST bodies) in src/Util/PHP/eval-stdin.php instead of php://stdin, effectively reading an empty string and thus not executing anything.
 [2016-11-14 14:26 UTC] deviantintegral at gmail dot com
Thanks! I'll followup with phpunit. I'm curious, why would this behaviour be different between the PHP CLI and phpdbg? Is there some sort of mapping of stdin to input that the cli binary does? I'm a little surprised you don't end up with an empty body there as well.
 [2016-11-14 14:39 UTC] bwoebi@php.net
Just for the record, I already have fixed it in phpunit: https://github.com/sebastianbergmann/phpunit/pull/2356

Also, the bug was inside phpdbg specific code (i.e. inside an if (PHP_SAPI == 'phpdbg')), that's why.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC