Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test in Symfony's HttpFoundation failing with websupport-sk/pecl-memcache under PHP 7 #7

Open
ymc-dabe opened this issue Feb 28, 2016 · 3 comments · Fixed by #76
Open

Comments

@ymc-dabe
Copy link

Note: Referencing this from symfony/symfony#17873 in which a proposed fix for Symfony was rejected with the wish to fix this upstream (in websupport-sk/pecl-memcache).

Problem

Using websupport-sk/pecl-memcache (branch php7 / commit 88750b4) with PHP 7 a test in Symfony's HttpFoundation (v3.0.2) component is failing with the following error:

# php7.0 -f /tmp/phpunit.phar -- src/Symfony/Component/HttpFoundation
PHPUnit 5.2.9 by Sebastian Bergmann and contributors.

...............................................................  63 / 809 (  7%)
................................................S.............. 126 / 809 ( 15%)
...................................................S........... 189 / 809 ( 23%)
............................................................... 252 / 809 ( 31%)
............................................................... 315 / 809 ( 38%)
..............................................SS............... 378 / 809 ( 46%)
S.............................................................. 441 / 809 ( 54%)
............................................................... 504 / 809 ( 62%)
............................................................... 567 / 809 ( 70%)
............................................................... 630 / 809 ( 77%)
........................................................E...... 693 / 809 ( 85%)
..SSSSSSSSSSSSSSSSSSSSSS..........SSSSSSSSSSSSSSS.............. 756 / 809 ( 93%)
.....................................................           809 / 809 (100%)

Time: 8.4 seconds, Memory: 14.00Mb

There was 1 error:

1) Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\MemcacheSessionHandlerTest::testReadSession
Missing argument 2 for Mock_Memcache_f8a5b6df::get(), called in /tmp/dabe/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php on line 82 and defined

/tmp/dabe/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php:82
/tmp/dabe/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php:72

FAILURES!
Tests: 1239, Assertions: 1658, Errors: 1, Skipped: 42.

This does does not happen with the PHP5 version of websupport-sk/pecl-memcache (branch NON_BLOCKING_IO_php7 / commit fdbd46b):

# php5 -f /tmp/phpunit.phar -- src/Symfony/Component/HttpFoundation
PHPUnit 5.2.9 by Sebastian Bergmann and contributors.

...............................................................  63 / 809 (  7%)
................................................S.............. 126 / 809 ( 15%)
...................................................S........... 189 / 809 ( 23%)
............................................................... 252 / 809 ( 31%)
............................................................... 315 / 809 ( 38%)
..............................................SS............... 378 / 809 ( 46%)
S.............................................................. 441 / 809 ( 54%)
............................................................... 504 / 809 ( 62%)
............................................................... 567 / 809 ( 70%)
............................................................... 630 / 809 ( 77%)
............................................................... 693 / 809 ( 85%)
..SSSSSSSSSSSSSSSSSSSSSS..........SSSSSSSSSSSSSSS.............. 756 / 809 ( 93%)
.....................................................           809 / 809 (100%)

Time: 10.24 seconds, Memory: 23.25Mb

OK, but incomplete, skipped, or risky tests!
Tests: 1239, Assertions: 1660, Skipped: 42.

How to reproduce

  • Build websupport-sk/pecl-memcache for php7 and configure php7 to use it
  • Get composer and phpunit in place
  • Checkout Symfony:
    # git clone https://github.com/symfony/symfony.git && cd symfony
  • Reset Symfony to v3.0.2:
    # git reset --hard v3.0.2
  • Install dependencies using composer:
    # composer install
  • Run tests for HttpFoundation component:
    # phpunit src/Symfony/Component/HttpFoundation

Further information

The mocked object generated by phpunit is different for the php7 and the php5 version:

diff -u php5.mock.php php7.mock.php 
--- php5.mock.php   2016-02-28 12:08:01.521713978 +0100
+++ php7.mock.php   2016-02-28 12:06:48.600997172 +0100
@@ -1,4 +1,4 @@
-class Mock_Memcache_988c5512 extends Memcache implements PHPUnit_Framework_MockObject_MockObject
+class Mock_Memcache_2739b378 extends Memcache implements PHPUnit_Framework_MockObject_MockObject
 {
     private $__phpunit_invocationMocker;
     private $__phpunit_originalObject;
@@ -316,15 +316,15 @@
         return $result;
     }

-    public function get()
+    public function get($arg0, &$arg1, &$arg2)
     {
-        $arguments = array();
+        $arguments = array($arg0, &$arg1, &$arg2);
         $count     = func_num_args();

-        if ($count > 0) {
+        if ($count > 3) {
             $_arguments = func_get_args();

-            for ($i = 0; $i < $count; $i++) {
+            for ($i = 3; $i < $count; $i++) {
                 $arguments[] = $_arguments[$i];
             }
         }

Thus I suspect to the php7 version exposes something different through the reflection API, than the php5 version does.

@szabolcsbalogh
Copy link
Contributor

i reproduced it, skips are because of missing memcached (not memcache), and mongo, ...
i have 2 failing tests

PHPUnit 5.2.10 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.0.5-dev
Configuration: /home/baloghsz/src/pecl-memcache/test2/symfony/phpunit.xml.dist

...............................................................  63 / 809 (  7%)
............................................................... 126 / 809 ( 15%)
...................................................S........... 189 / 809 ( 23%)
............................................................... 252 / 809 ( 31%)
............................................................... 315 / 809 ( 38%)
..............................................SS............... 378 / 809 ( 46%)
S.............................................................. 441 / 809 ( 54%)
............................................................... 504 / 809 ( 62%)
............................................................... 567 / 809 ( 70%)
............................................................... 630 / 809 ( 77%)
........................................................E...... 693 / 809 ( 85%)
..SSSSSSSSSSSSSSSSSSSSSS.....E................................. 756 / 809 ( 93%)
.....................................................           809 / 809 (100%)

Time: 5.73 seconds, Memory: 14.00Mb

There were 2 errors:

1) Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\MemcacheSessionHandlerTest::testReadSession
Missing argument 2 for Mock_Memcache_75ed4e5a::get(), called in /home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php on line 82 and defined

/home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php:82
/home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php:72

2) Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\NativeFileSessionHandlerTest::testConstructDefault
is_dir(): Unable to find the wrapper "tcp" - did you forget to enable it when you configured PHP?

/home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php:51
/home/baloghsz/src/pecl-memcache/test2/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php:72
  1. mock. It is about function get, implemented as PHP_FUNCTION(memcache_get).
    in input parameters there is no change, so what i changed:
    This function uses zend_parse_parameters, and is returning flags to a reference from function parameters. There was a change in references, so if i would to do it in php7, i needed to define it in https://github.com/websupport-sk/pecl-memcache/blob/NON_BLOCKING_IO_php7/php7/memcache.c#L96, so there was added definition https://github.com/websupport-sk/pecl-memcache/blob/NON_BLOCKING_IO_php7/php7/memcache.c#L48, which there wasn't before.

    So parameters as seen in zend_parse_parameters were not changed, but there is added a definition, so now mock can discover about parameters. Can I overcome this in this module, or should be fixed elsewhere?

  2. I don't know why is NativeFileSessionHandlerTest testing session.save_path if session.save_handler = "memcache". I didn't changed naming of configuration parameters for this module, so this should be the same for php5 before, but i didn't verified this.

@pierrejoye
Copy link
Collaborator

Not sure about #2. I have to check.

for #1, arg_info is missing for many APIs, we should definitively complete them at some points :) That looks like what is used by phpunit to valid the mock interface.

@ccovey
Copy link

ccovey commented Jul 8, 2016

@pierrejoye I am noticing this also on our current build. Do you have an ETA For #1 (or even a work around?).

This was referenced Oct 8, 2020
@thesource93 thesource93 linked a pull request Oct 16, 2020 that will close this issue
bof added a commit to bof/pecl-memcache that referenced this issue Feb 13, 2023
In an attempt to provoke the debug build assertion failure I saw, this
is the first attempt at a test case provoking it.

Doesn't work, yet...

Context on the assertion failure:

  websupport-sk#4  0x00007fc675426c46 in __assert_fail () from /lib64/libc.so.6
  websupport-sk#5  0x00007fc670cbcaf3 in zend_gc_delref (p=0x7fc670bbc000) at /opt/php/include/php/Zend/zend_types.h:1209
  websupport-sk#6  0x00007fc670cbcb59 in zval_delref_p (pz=0x7ffe587973a0) at /opt/php/include/php/Zend/zend_types.h:1245
  websupport-sk#7  0x00007fc670cbcc81 in zval_ptr_dtor_nogc (zval_ptr=0x7ffe587973a0) at /opt/php/include/php/Zend/zend_variables.h:34
  websupport-sk#8  0x00007fc670cbdcbc in ps_read_memcache (mod_data=0x7fc674bed980 <ps_globals+96>, key=0x7fc670b81540, val=0x7ffe58797428,
      maxlifetime=3600) at /srv/dev/yin/phb/build/ourphp-8.1.15-debug/memcache/src/memcache_session.c:385
  websupport-sk#9  0x00007fc673cd7ab3 in php_session_initialize ()
      at /srv/dev/yin/phb/build/ourphp-8.1.15-debug/php-src/ext/session/session.c:444
  websupport-sk#10 0x00007fc673cdafa3 in php_session_start () at /srv/dev/yin/phb/build/ourphp-8.1.15-debug/php-src/ext/session/session.c:1612
  websupport-sk#11 0x00007fc673cded07 in zif_session_start (execute_data=0x7fc670a12d30, return_value=0x7fc670a12d10)
      at /srv/dev/yin/phb/build/ourphp-8.1.15-debug/php-src/ext/session/session.c:2533
  websupport-sk#12 0x00007fc673feea58 in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER ()
      at /srv/dev/yin/phb/build/ourphp-8.1.15-debug/php-src/Zend/zend_vm_execute.h:1297
  websupport-sk#13 0x00007fc674063f3c in execute_ex (ex=0x7fc670a12930)
      at /srv/dev/yin/phb/build/ourphp-8.1.15-debug/php-src/Zend/zend_vm_execute.h:55779
  websupport-sk#14 0x00007fc673f9a4c3 in zend_call_function (fci=0x7ffe58797990, fci_cache=0x7ffe58797970)
      at /srv/dev/yin/phb/build/ourphp-8.1.15-debug/php-src/Zend/zend_execute_API.c:912
  websupport-sk#15 0x00007fc673f9a97d in zend_call_known_function (fn=0x7fc610866500, object=0x0, called_scope=0x0, retval_ptr=0x0,
      param_count=1, params=0x7ffe58797a20, named_params=0x0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants