hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Modifying an array nested in an ArrayObject by reference segfaults

Open jmarrama opened this issue 12 years ago • 3 comments

function main()
{
  $ao = new ArrayObject();
  $ao['foo'] = ['bar' => 'baz'];
  $innerArr = &$ao['foo'];
  $innerArr[] = 42;
  var_dump($ao);
}
main();

Running this with -vEval.Jit=true segfaults.

Also, the outputs of HHVM (without the jit on) and Zend slightly differ. HHVM outputs:

object(ArrayObject)#1 (1) {
  ["foo"]=>
    &array(2) {
    ["bar"]=>
    string(3) "baz"
    [0]=>
    int(42)
  }
}

Zend outputs:

class ArrayObject#4 (1) {
  public $foo =>
    array(2) {
    'bar' =>
    string(3) "baz"
    [0] =>
    int(42)
  }
}

jmarrama avatar Mar 01 '14 00:03 jmarrama

Thanks for reporting this. Feel free to submit a PR if you (or someone else reading this) gets to this before we do.

fredemmott avatar Mar 03 '14 16:03 fredemmott

I committed a fix for this locally which should go out with the next push.

swtaarrs avatar Mar 15 '14 06:03 swtaarrs

many many thanks @swtaarrs my unit tests are almost 100%!

franz-deleon avatar Mar 18 '14 14:03 franz-deleon