Commits

rickysu  committed 1484d72 Merge

Merge remote-tracking branch 'upstream/master'

  • Participants
  • Parent commits 54f3795, 63c0333

Comments (0)

Files changed (3)

     <email>osmanov@php.net</email>
     <active>yes</active>
   </lead>
-  <date>2013-07-29</date>
+  <date>2013-08-10</date>
   <!--{{{ Current version -->
   <version>
     <release>1.7.3</release>
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
   <notes><![CDATA[
-  Fix: in php_event.c write_property function wasn't static
+  Fix: in php_event.c write_property function was non-static
+  Fix: absence of get_gc property handler caused segfaults with gc_collect_cycles()
   ]]></notes>
   <!--}}}-->
   <!--{{{ Contents -->
         <file role="src" name="08-buffer.phpt"/>
         <file role="src" name="09-gc-cycles.phpt"/>
         <file role="src" name="10-event-data-dtor.phpt"/>
+        <file role="src" name="11-gc-cycles.phpt"/>
       </dir>
     </dir>
   </contents>
   </extsrcrelease>
   <!--{{{ changelog-->
   <changelog>
-    <!--{{{ Current version -->
+    <!--{{{ 1.7.3 -->
     <release>
       <version>
         <release>1.7.3</release>
       </stability>
       <license uri="http://www.php.net/license">PHP</license>
       <notes><![CDATA[
-  Fix: in php_event.c write_property function wasn't static
+  Fix: in php_event.c write_property function was non-static
+  Fix: absence of get_gc property handler caused segfaults with gc_collect_cycles()
   ]]></notes>
     </release>
     <!--}}}-->
 	ulong                        num_key;
 
 	obj = (php_event_abstract_object_t *) zend_objects_get_address(object TSRMLS_CC);
-	props = zend_std_get_properties(object TSRMLS_CC);
+	/*props = zend_std_get_properties(object TSRMLS_CC);*/
+	props = obj->zo.properties;
 
 	if (obj->prop_handler) {
 		zend_hash_internal_pointer_reset_ex(obj->prop_handler, &pos);
 /* }}} */
 #endif
 
+static HashTable *get_gc(zval *object, zval ***table, int *n TSRMLS_DC)
+{
+	*table = NULL;
+	*n = 0;
+	return zend_std_get_properties(object TSRMLS_CC);
+}
+
+
 #define PHP_EVENT_ADD_CLASS_PROPERTIES(a, b)                                           \
 {                                                                                      \
     int i = 0;                                                                         \
 #if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4
 	object_handlers.get_properties       = get_properties;
 #endif
+	object_handlers.get_gc               = get_gc;
 
 	zend_hash_init(&classes, 8, NULL, NULL, 1);
 	register_classes(TSRMLS_C);

File tests/11-gc-cycles.phpt

+--TEST--
+Check for get_gc property handler
+--FILE--
+<?php
+ 
+class x {
+        public $t = null;
+ 
+        public function __construct() {
+                $this->t = Event::timer(new EventBase(), function () { });
+                $this->t->free();
+        }
+}
+ 
+
+echo "1";
+new x();
+gc_collect_cycles();
+echo "2"; // we had segfault here
+?>
+--EXPECT--
+12