3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * segfault test * * I encountered during app bug hunt, whereby instead of * `$w->method()` it called `$this->method()`. * * However, I discovered that infinite recursion which * usually triggers memory limit or max_recursion_depth * * For minimal testcase for segfault see: method4() */ class Y { public function method() { } } class X { public function method(): array { $ws = [new Y]; return array_map(function ($w) { return ['id' => 3, 'something' => $this->method()]; // this effectivly recurses (I was debugging a typo, this should have been `$w->method()`) }, $ws); } public function method2() { $this->method2(); } public function method3() { $a = function (){ $this->method3(); }; $a(); } // minimal testcase for segfault <---------------------- MINIMAL TESTCASE public function method4() { $a = function (){ $this->method4(); }; array_map($a,[1]); } } // original test-harnes // (new X)->method(); // Allowed memory size exhausted // (new X)->method2(); // also, Allowed memory size exhausted //(new X)->method3(); // minimal testcase for segfault (new X)->method4();

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AajsP
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   NEW                                              $0      'X'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $0, 'method4'
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Class Y:
Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AajsP
function name:  method
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E > > RETURN                                                   null

End of function method

End of class Y.

Class X:
Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AajsP
function name:  method
number of ops:  13
compiled vars:  !0 = $ws
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'Y'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~3      $1
          3        ASSIGN                                                   !0, ~3
   27     4        INIT_FCALL                                               'array_map'
          5        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   30     6        SEND_VAL                                                 ~5
          7        SEND_VAR                                                 !0
   27     8        DO_ICALL                                         $6      
   30     9        VERIFY_RETURN_TYPE                                       $6
         10      > RETURN                                                   $6
   31    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AajsP
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $w
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        INIT_ARRAY                                       ~1      3, 'id'
          2        FETCH_THIS                                       $2      
          3        INIT_METHOD_CALL                                         $2, 'method'
          4        DO_FCALL                                      0  $3      
          5        ADD_ARRAY_ELEMENT                                ~1      $3, 'something'
          6      > RETURN                                                   ~1
   30     7*     > RETURN                                                   null

End of Dynamic Function 0

End of function method

Function method2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AajsP
function name:  method2
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_METHOD_CALL                                         'method2'
          1        DO_FCALL                                      0          
   36     2      > RETURN                                                   null

End of function method2

Function method3:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AajsP
function name:  method3
number of ops:  5
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          1        ASSIGN                                                   !0, ~1
   41     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0          
   42     4      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AajsP
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   FETCH_THIS                                       $0      
          1        INIT_METHOD_CALL                                         $0, 'method3'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   null

End of Dynamic Function 0

End of function method3

Function method4:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AajsP
function name:  method4
number of ops:  7
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          1        ASSIGN                                                   !0, ~1
   48     2        INIT_FCALL                                               'array_map'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <array>
          5        DO_ICALL                                                 
   49     6      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AajsP
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   FETCH_THIS                                       $0      
          1        INIT_METHOD_CALL                                         $0, 'method4'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   null

End of Dynamic Function 0

End of function method4

End of class X.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.7 ms | 2075 KiB | 12 Q