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

Segmentation fault #19

Open
RootYQ opened this issue Sep 14, 2020 · 0 comments
Open

Segmentation fault #19

RootYQ opened this issue Sep 14, 2020 · 0 comments

Comments

@RootYQ
Copy link

RootYQ commented Sep 14, 2020

类定义:

class Foo
{
    protected $relations = [];

    protected $name = 2;

    /**
     * Set the specific relationship in the model.
     *
     * @param  string  $relation
     * @param  mixed  $value
     * @return $this
     */
    public function setRelation($relation, $value)
    {
        $this->relations[$relation] = $value;

        return $this;
    }
}

序列化方法

function encode($result)
{
      $stream = new BytesIO();
      $writer = new Writer($stream, false);
      $stream->write(Tags::TagResult);
      if (0 === ResultMode::Serialized) {
          $stream->write($result);
      }
      else {
          $writer->reset();
          $writer->serialize($result);
       }

      $data = $stream->toString();

      return $data;
}

调用:

$foo = new Foo();
$foo_2 = new Foo();
$foo->setRelation('sublabel', [$foo_2]);
var_dump(encode($foo));

会触发Segmentation fault, 调试了一下,里面的循环会影响到外面循环的nInternalPointer, 没再继续研究, 求助大佬帮忙看一下……^_^
(环境: php: 7.1.6, hprose: master版本也可以复现)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant