Comment 6 for bug 577710

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Vladimir, thanks very much for this bug report!

I believe this is essentially infinite recursion caused by the way PHP resolves methods..

the test case basically does this

create a new Test_PHP5 object, named $this
call $this->__construct()
$this->__construct calls parent::Test(), which leaves $this as a Test_PHP5, and maps to Test::Test()
Test::Test() calls $this->__construct(), which is mapped to Test_PHP5::__construct()
$this->__construct() calls parent::Test() which maps to Test::Test()
... infinite recursion

This would cause issues with any PHP interpreter. On Maverick though, this is the result:

PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in /home/clint/test.php on line 7
PHP Stack trace:
PHP 1. {main}() /home/clint/test.php:0
PHP 2. Test_PHP5->__construct() /home/clint/test.php:26
PHP 3. Test->Test() /home/clint/test.php:22
PHP 4. Test_PHP5->__construct() /home/clint/test.php:7
PHP 5. Test->Test() /home/clint/test.php:22
PHP 6. Test_PHP5->__construct() /home/clint/test.php:7
PHP 7. Test->Test() /home/clint/test.php:22
PHP 8. Test_PHP5->__construct() /home/clint/test.php:7
PHP 9. Test->Test() /home/clint/test.php:22
PHP 10. Test_PHP5->__construct() /home/clint/test.php:7
PHP 11. Test->Test() /home/clint/test.php:22
PHP 12. Test_PHP5->__construct() /home/clint/test.php:7
PHP 13. Test->Test() /home/clint/test.php:22
PHP 14. Test_PHP5->__construct() /home/clint/test.php:7
PHP 15. Test->Test() /home/clint/test.php:22
PHP 16. Test_PHP5->__construct() /home/clint/test.php:7
PHP 17. Test->Test() /home/clint/test.php:22
PHP 18. Test_PHP5->__construct() /home/clint/test.php:7
PHP 19. Test->Test() /home/clint/test.php:22
PHP 20. Test_PHP5->__construct() /home/clint/test.php:7
PHP 21. Test->Test() /home/clint/test.php:22
PHP 22. Test_PHP5->__construct() /home/clint/test.php:7
PHP 23. Test->Test() /home/clint/test.php:22
PHP 24. Test_PHP5->__construct() /home/clint/test.php:7
PHP 25. Test->Test() /home/clint/test.php:22
PHP 26. Test_PHP5->__construct() /home/clint/test.php:7
PHP 27. Test->Test() /home/clint/test.php:22
PHP 28. Test_PHP5->__construct() /home/clint/test.php:7
PHP 29. Test->Test() /home/clint/test.php:22
PHP 30. Test_PHP5->__construct() /home/clint/test.php:7
PHP 31. Test->Test() /home/clint/test.php:22
PHP 32. Test_PHP5->__construct() /home/clint/test.php:7
PHP 33. Test->Test() /home/clint/test.php:22
PHP 34. Test_PHP5->__construct() /home/clint/test.php:7
PHP 35. Test->Test() /home/clint/test.php:22
PHP 36. Test_PHP5->__construct() /home/clint/test.php:7
PHP 37. Test->Test() /home/clint/test.php:22
PHP 38. Test_PHP5->__construct() /home/clint/test.php:7
PHP 39. Test->Test() /home/clint/test.php:22
PHP 40. Test_PHP5->__construct() /home/clint/test.php:7
PHP 41. Test->Test() /home/clint/test.php:22
PHP 42. Test_PHP5->__construct() /home/clint/test.php:7
PHP 43. Test->Test() /home/clint/test.php:22
PHP 44. Test_PHP5->__construct() /home/clint/test.php:7
PHP 45. Test->Test() /home/clint/test.php:22
PHP 46. Test_PHP5->__construct() /home/clint/test.php:7
PHP 47. Test->Test() /home/clint/test.php:22
PHP 48. Test_PHP5->__construct() /home/clint/test.php:7
PHP 49. Test->Test() /home/clint/test.php:22
PHP 50. Test_PHP5->__construct() /home/clint/test.php:7
PHP 51. Test->Test() /home/clint/test.php:22
PHP 52. Test_PHP5->__construct() /home/clint/test.php:7
PHP 53. Test->Test() /home/clint/test.php:22
PHP 54. Test_PHP5->__construct() /home/clint/test.php:7
PHP 55. Test->Test() /home/clint/test.php:22
PHP 56. Test_PHP5->__construct() /home/clint/test.php:7
PHP 57. Test->Test() /home/clint/test.php:22
PHP 58. Test_PHP5->__construct() /home/clint/test.php:7
PHP 59. Test->Test() /home/clint/test.php:22
PHP 60. Test_PHP5->__construct() /home/clint/test.php:7
PHP 61. Test->Test() /home/clint/test.php:22
PHP 62. Test_PHP5->__construct() /home/clint/test.php:7
PHP 63. Test->Test() /home/clint/test.php:22
PHP 64. Test_PHP5->__construct() /home/clint/test.php:7
PHP 65. Test->Test() /home/clint/test.php:22
PHP 66. Test_PHP5->__construct() /home/clint/test.php:7
PHP 67. Test->Test() /home/clint/test.php:22
PHP 68. Test_PHP5->__construct() /home/clint/test.php:7
PHP 69. Test->Test() /home/clint/test.php:22
PHP 70. Test_PHP5->__construct() /home/clint/test.php:7
PHP 71. Test->Test() /home/clint/test.php:22
PHP 72. Test_PHP5->__construct() /home/clint/test.php:7
PHP 73. Test->Test() /home/clint/test.php:22
PHP 74. Test_PHP5->__construct() /home/clint/test.php:7
PHP 75. Test->Test() /home/clint/test.php:22
PHP 76. Test_PHP5->__construct() /home/clint/test.php:7
PHP 77. Test->Test() /home/clint/test.php:22
PHP 78. Test_PHP5->__construct() /home/clint/test.php:7
PHP 79. Test->Test() /home/clint/test.php:22
PHP 80. Test_PHP5->__construct() /home/clint/test.php:7
PHP 81. Test->Test() /home/clint/test.php:22
PHP 82. Test_PHP5->__construct() /home/clint/test.php:7
PHP 83. Test->Test() /home/clint/test.php:22
PHP 84. Test_PHP5->__construct() /home/clint/test.php:7
PHP 85. Test->Test() /home/clint/test.php:22
PHP 86. Test_PHP5->__construct() /home/clint/test.php:7
PHP 87. Test->Test() /home/clint/test.php:22
PHP 88. Test_PHP5->__construct() /home/clint/test.php:7
PHP 89. Test->Test() /home/clint/test.php:22
PHP 90. Test_PHP5->__construct() /home/clint/test.php:7
PHP 91. Test->Test() /home/clint/test.php:22
PHP 92. Test_PHP5->__construct() /home/clint/test.php:7
PHP 93. Test->Test() /home/clint/test.php:22
PHP 94. Test_PHP5->__construct() /home/clint/test.php:7
PHP 95. Test->Test() /home/clint/test.php:22
PHP 96. Test_PHP5->__construct() /home/clint/test.php:7
PHP 97. Test->Test() /home/clint/test.php:22
PHP 98. Test_PHP5->__construct() /home/clint/test.php:7
PHP 99. Test->Test() /home/clint/test.php:22

As you can see, Test::__construct() is never called.

When I run your test script on lucid with the latest updates, it actually just sits there and doesn't return anything, nor does it segfault.

As far as I know, you can't really access overriden methods from the parent itself, you have to call parent::methodname from the overriding method to get to that old code. Given the situation above, the right way to solve this problem is not to call parent::Test(), but parent::__construct().

I'm going to close this report as invalid, but please feel free to re-open it (set it to New) if you feel that I have misunderstood the intent of the test case or if you have a different test case that shows the crash without overloading the stack.