Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed issue #797: Xdebug crashes when fetching static properties.

  • Loading branch information...
commit cc7fd703e6ba052acc34b508f82cc3c7f1c9972f 1 parent 3ff4076
@derickr authored
Showing with 30 additions and 54 deletions.
  1. +15 −13 tests/bug00797.inc
  2. +11 −41 tests/bug00797.phpt
  3. +4 −0 xdebug_var.c
View
28 tests/bug00797.inc
@@ -1,17 +1,19 @@
<?php
-class Base {
- static public $property = true;
-
- static public function basetest( ) {
- echo 'blah blah blah';
- }
-}
+$a = new A;
+
+class A {
+// private $a;
-class Test extends Base {
- public function test( ) {
- static::basetest( );
- }
+ function __construct() {
+ $this->a = B::foo();
+ }
}
-$test = new Test;
-$test->test( );
+class B {
+ private $b;
+
+ static public function foo() {
+ return "I'm alive!";
+ }
+}
+?>
View
52 tests/bug00797.phpt
@@ -6,16 +6,10 @@ require 'dbgp/dbgpclient.php';
$data = file_get_contents(dirname(__FILE__) . '/bug00797.inc');
$commands = array(
- 'breakpoint_set -t line -n 6 -f file:///tmp/xdebug-dbgp-test.php',
- 'run',
- 'stack_get',
- 'stack_get -d 0',
- 'context_get -d 1',
- 'property_get -d 1 -n $this',
- 'property_get -d 1 -n $this::property',
+ 'step_into',
+ 'step_into',
+ 'step_into',
'context_get -d 0',
- 'property_get -d 0 -n ::',
- 'property_get -d 0 -n ::property',
);
dbgpRun( $data, $commands );
@@ -24,42 +18,18 @@ dbgpRun( $data, $commands );
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///tmp/xdebug-dbgp-test.php" language="PHP" protocol_version="1.0" appid="" idekey=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]></copyright></init>
--> breakpoint_set -i 1 -t line -n 6 -f file:///tmp/xdebug-dbgp-test.php
+-> step_into -i 1
<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="1" id=""></response>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="1" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="2"></xdebug:message></response>
--> run -i 2
+-> step_into -i 2
<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="2" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="6"></xdebug:message></response>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="2" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="8"></xdebug:message></response>
--> stack_get -i 3
+-> step_into -i 3
<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="3"><stack where="Base::basetest" level="0" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="6"></stack><stack where="Test-&gt;test" level="1" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="12"></stack><stack where="{main}" level="2" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="16"></stack></response>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="3" status="break" reason="ok"><xdebug:message filename="file:///tmp/xdebug-dbgp-test.php" lineno="16"></xdebug:message></response>
--> stack_get -i 4 -d 0
+-> context_get -i 4 -d 0
<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="4"><stack where="Base::basetest" level="0" type="file" filename="file:///tmp/xdebug-dbgp-test.php" lineno="6"></stack></response>
-
--> context_get -i 5 -d 1
-<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="5" context="0"><property name="$this" fullname="$this" address="" type="object" classname="Test" children="1" numchildren="1" page="0" pagesize="32"><property name="property" fullname="$this::property" facet="static public" address="" type="bool"><![CDATA[1]]></property></property></response>
-
--> property_get -i 6 -d 1 -n $this
-<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="6"><property name="$this" fullname="$this" address="" type="object" classname="Test" children="1" numchildren="1" page="0" pagesize="32"><property name="property" fullname="$this::property" facet="static public" address="" type="bool"><![CDATA[1]]></property></property></response>
-
--> property_get -i 7 -d 1 -n $this::property
-<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="7"><property name="$this::property" fullname="$this::property" address="" type="bool"><![CDATA[1]]></property></response>
-
--> context_get -i 8 -d 0
-<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="8" context="0"><property name="::" fullname="::" type="object" classname="Base" children="1" numchildren="1"><property name="::property" fullname="::property" address="" type="bool" facet="static public"><![CDATA[1]]></property></property></response>
-
--> property_get -i 9 -d 0 -n ::
-<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="9" status="break" reason="ok"><error code="300"><message><![CDATA[can not get property]]></message></error></response>
-
--> property_get -i 10 -d 0 -n ::property
-<?xml version="1.0" encoding="iso-8859-1"?>
-<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="10"><property name="::property" fullname="::property" address="" type="bool"><![CDATA[1]]></property></response>
+<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="::" fullname="::" type="object" classname="B" children="1" numchildren="1"></property></response>
View
4 xdebug_var.c
@@ -1067,6 +1067,10 @@ void xdebug_attach_property_with_contents(zend_property_info *prop_info XDEBUG_Z
class_entry = va_arg(args, zend_class_entry *);
class_name = va_arg(args, char *);
+ if ((prop_info->flags & ZEND_ACC_STATIC) == 0) {
+ return;
+ }
+
modifier = xdebug_get_property_info(prop_info->name, prop_info->name_length, &prop_name, &prop_class_name);
if (strcmp(modifier, "private") != 0 || strcmp(class_name, prop_class_name) == 0) {
Please sign in to comment.
Something went wrong with that request. Please try again.