colder / php-weakref

PECL extension that implements weak references and weak maps in PHP
http://pecl.php.net/weakref
Other
36 stars 13 forks source link

WeakMap + WeakRef Segfault #13

Closed mjhoag closed 9 years ago

mjhoag commented 9 years ago

Under PHP 5.4.4-14+deb7u14 with Weakref-0.2.4, the following segfaults:

<?php

class RefHolder {
    function __construct($o) { $this->o = new WeakRef($o); }
}

$o = new Stdclass();

$map = new WeakMap();
$map[$o] = [];
//unset($map[$o]);
$map[$o] = new RefHolder($o);

$o = new Stdclass();  // segfault

No extensions outside of weakref loaded. That is, ran as php -n -d extension=weakref.so segfault.php.

Uncommenting the unset() seems to work around the problem.

shoghicp commented 9 years ago

I can confirm this happens to me on PHP 5.6.1, on Windows 7, MacOS and all Linux distributions I've tested it on (including Ubuntu, CentOS, Android and Raspbian)

colder commented 9 years ago

Thanks for your report!

This should now be fixed in 94cb666f01343e2be5f8a9e3f26ee81f928499a3. It at least passes the testcase provided. Can you confirm it also solves your original issue?

mjhoag commented 9 years ago

@shoghicp: Thanks for verifying it wasn't just me. :)

@colder: It does indeed appear to have solved my original issue. Yay! Thanks!

colder commented 9 years ago

Great! I will do a release shortly.