解决 php7下 igbinary_unserialize_ref: invalid reference 的bug

  最近组内升级了PHP7,某个接口偶发502,看了下php的错误日志如下:

igbinary_unserialize_ref: invalid reference 4034265088 >= 0 in xxx.php on line 426
Memcached::getMulti(): could not unserialize value with igbinary in xxx.php on line 426

  组内的同事查了下,igbinary 的源码,抛出异常的代码为:

    if (n >= igsd->references_count) {
        zend_error(E_WARNING, "igbinary_unserialize_ref: invalid reference %zu >= %zu", (int) n, (int)igsd->references_count);
        return 1;
    }

  即是 igbinary 的引用计数出现了问题,导致了 segment fault, 进而导致出现 502,应该是 igbinary 这个扩展,对于php 7.0的兼容性问题

  进一步去看了 igbinary 近期的更新日志,发现,居然修复了这个bug,如下:

  这个是bug相关的连接:https://github.com/php-memcached-dev/php-memcached/issues/326

  这个是修复的详情: https://github.com/igbinary/igbinary/commit/b090b05ca301b64f4bebe2df8c79528c13c7176e

  至此,问题已经搞清楚了,解决这个问题有两种解决方案:

  (1)在用到 igbinary 代码中不要使用引用

  (2)更新 igbinary 的扩展

  当然更推荐第二种方式。

posted @ 2017-07-11 11:22  talk_is_cheap  阅读(1906)  评论(0编辑  收藏  举报