felixfbecker / php-language-server

PHP Implementation of the VS Code Language Server Protocol šŸ†šā†”šŸ–„
ISC License
1.16k stars 185 forks source link

LanguageServer\Index\StubsIndex read method unserialize causes PHP Fatal error: Allowed memory size #453

Open banfg56 opened 7 years ago

banfg56 commented 7 years ago

Info

Problem

LanguageServer\Index\StubsIndex read method unserialize causes PHP Fatal error: Allowed memory size

Reproducible Case

unserialize causes PHP Fatal error: Allowed memory size

PHP debug trace:

array(19) {
  [0]=>
  array(6) {
    ["file"]=>
    string(127) "/home/banfg56/.vscode/extensions/felixfbecker.php-intellisense-1.3.0/vendor/felixfbecker/language-server/src/LanguageServer.php"
    ["line"]=>
    int(191)
    ["function"]=>
    string(4) "read"
    ["class"]=>
    string(31) "LanguageServer\Index\StubsIndex"
    ["type"]=>
    string(2) "::"
    ["args"]=>
    array(0) {
    }
  }
  [1]=>
  array(5) {
    ["function"]=>
    string(24) "LanguageServer\{closure}"
    ["class"]=>
    string(29) "LanguageServer\LanguageServer"
    ["object"]=>
    object(LanguageServer\LanguageServer)#4 (23) {
      ["textDocument"]=>
      NULL
      ["workspace"]=>
      NULL
      ["window"]=>
      NULL
      ["telemetry"]=>
      NULL
      ["completionItem"]=>
      NULL
      ["codeLens"]=>
      NULL
      ["protocolReader":protected]=>
      object(LanguageServer\ProtocolStreamReader)#14 (6) {
        ["input":"LanguageServer\ProtocolStreamReader":private]=>
        resource(1) of type (stream)
        ["parsingMode":"LanguageServer\ProtocolStreamReader":private]=>
        int(2)
        ["buffer":"LanguageServer\ProtocolStreamReader":private]=>
        string(1223) "{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":5427,"rootPath":"/data/companywork/Econtract","rootUri":"file:///data/companywork/Econtract","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true}},"textDocument":{"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true}},"hover":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true},"codeAction":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true}}},"trace":"off"}}"
        ["headers":"LanguageServer\ProtocolStreamReader":private]=>
        array(1) {
          ["Content-Length"]=>
          string(4) "1223"
        }
        ["contentLength":"LanguageServer\ProtocolStreamReader":private]=>
        int(1223)
        ["listeners":protected]=>
        array(2) {
          ["close"]=>
          array(3) {
            [0]=>
            bool(false)
            [1]=>
            array(2) {
              [0]=>
              int(100)
              [1]=>
              int(100)
            }
            [2]=>
            array(2) {
              [0]=>
              object(Closure)#15 (1) {
                ["this"]=>
                *RECURSION*
              }
              [1]=>
              object(Closure)#17 (1) {
                ["this"]=>
                *RECURSION*
              }
            }
          }
          ["message"]=>
          array(3) {
            [0]=>
            bool(true)
            [1]=>
            array(1) {
              [0]=>
              int(100)
            }
            [2]=>
            array(1) {
              [0]=>
              object(Closure)#18 (2) {
                ["this"]=>
                *RECURSION*
                ["parameter"]=>
                array(1) {
                  ["$msg"]=>
                  string(10) "<required>"
                }
              }
            }
          }
        }
      }
      ["protocolWriter":protected]=>
      object(LanguageServer\ProtocolStreamWriter)#13 (2) {
        ["output":"LanguageServer\ProtocolStreamWriter":private]=>
        resource(2) of type (stream)
        ["messages":"LanguageServer\ProtocolStreamWriter":private]=>
        array(0) {
        }
      }
      ["client":protected]=>
      object(LanguageServer\LanguageClient)#19 (4) {
        ["textDocument"]=>
        object(LanguageServer\Client\TextDocument)#23 (2) {
          ["handler":"LanguageServer\Client\TextDocument":private]=>
          object(LanguageServer\ClientHandler)#20 (3) {
            ["protocolReader"]=>
            object(LanguageServer\ProtocolStreamReader)#14 (6) {
              ["input":"LanguageServer\ProtocolStreamReader":private]=>
              resource(1) of type (stream)
              ["parsingMode":"LanguageServer\ProtocolStreamReader":private]=>
              int(2)
              ["buffer":"LanguageServer\ProtocolStreamReader":private]=>
              string(1223) "{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":5427,"rootPath":"/data/companywork/Econtract","rootUri":"file:///data/companywork/Econtract","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true}},"textDocument":{"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true}},"hover":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true},"codeAction":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true}}},"trace":"off"}}"
              ["headers":"LanguageServer\ProtocolStreamReader":private]=>
              array(1) {
                ["Content-Length"]=>
                string(4) "1223"
              }
              ["contentLength":"LanguageServer\ProtocolStreamReader":private]=>
              int(1223)
              ["listeners":protected]=>
              array(2) {
                ["close"]=>
                array(3) {
                  [0]=>
                  bool(false)
                  [1]=>
                  array(2) {
                    [0]=>
                    int(100)
                    [1]=>
                    int(100)
                  }
                  [2]=>
                  array(2) {
                    [0]=>
                    object(Closure)#15 (1) {
                      ["this"]=>
                      *RECURSION*
                    }
                    [1]=>
                    object(Closure)#17 (1) {
                      ["this"]=>
                      *RECURSION*
                    }
                  }
                }
                ["message"]=>
                array(3) {
                  [0]=>
                  bool(true)
                  [1]=>
                  array(1) {
                    [0]=>
                    int(100)
                  }
                  [2]=>
                  array(1) {
                    [0]=>
                    object(Closure)#18 (2) {
                      ["this"]=>
                      *RECURSION*
                      ["parameter"]=>
                      array(1) {
                        ["$msg"]=>
                        string(10) "<required>"
                      }
                    }
                  }
                }
              }
            }
            ["protocolWriter"]=>
            object(LanguageServer\ProtocolStreamWriter)#13 (2) {
              ["output":"LanguageServer\ProtocolStreamWriter":private]=>
              resource(2) of type (stream)
              ["messages":"LanguageServer\ProtocolStreamWriter":private]=>
              array(0) {
              }
            }
            ["idGenerator"]=>
            object(LanguageServer\IdGenerator)#21 (1) {
              ["counter"]=>
              int(1)
            }
          }
          ["mapper":"LanguageServer\Client\TextDocument":private]=>
          object(JsonMapper)#22 (10) {
            ["logger":protected]=>
            NULL
            ["bExceptionOnUndefinedProperty"]=>
            bool(false)
            ["bExceptionOnMissingData"]=>
            bool(false)
            ["bEnforceMapType"]=>
            bool(true)
            ["bStrictObjectTypeChecking"]=>
            bool(false)
            ["bStrictNullTypes"]=>
            bool(true)
            ["bIgnoreVisibility"]=>
            bool(false)
            ["classMap"]=>
            array(0) {
            }
            ["undefinedPropertyHandler"]=>
            NULL
            ["arInspectedClasses":protected]=>
            array(0) {
            }
          }
        }
        ["window"]=>
        object(LanguageServer\Client\Window)#24 (1) {
          ["handler":"LanguageServer\Client\Window":private]=>
          object(LanguageServer\ClientHandler)#20 (3) {
            ["protocolReader"]=>
            object(LanguageServer\ProtocolStreamReader)#14 (6) {
              ["input":"LanguageServer\ProtocolStreamReader":private]=>
              resource(1) of type (stream)
              ["parsingMode":"LanguageServer\ProtocolStreamReader":private]=>
              int(2)
              ["buffer":"LanguageServer\ProtocolStreamReader":private]=>
              string(1223) "{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":5427,"rootPath":"/data/companywork/Econtract","rootUri":"file:///data/companywork/Econtract","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true}},"textDocument":{"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true}},"hover":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true},"codeAction":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true}}},"trace":"off"}}"
              ["headers":"LanguageServer\ProtocolStreamReader":private]=>
              array(1) {
                ["Content-Length"]=>
                string(4) "1223"
              }
              ["contentLength":"LanguageServer\ProtocolStreamReader":private]=>
              int(1223)
              ["listeners":protected]=>
              array(2) {
                ["close"]=>
                array(3) {
                  [0]=>
                  bool(false)
                  [1]=>
                  array(2) {
                    [0]=>
                    int(100)
                    [1]=>
                    int(100)
                  }
                  [2]=>
                  array(2) {
                    [0]=>
                    object(Closure)#15 (1) {
                      ["this"]=>
                      *RECURSION*
                    }
                    [1]=>
                    object(Closure)#17 (1) {
                      ["this"]=>
                      *RECURSION*
                    }
                  }
                }
                ["message"]=>
                array(3) {
                  [0]=>
                  bool(true)
                  [1]=>
                  array(1) {
                    [0]=>
                    int(100)
                  }
                  [2]=>
                  array(1) {
                    [0]=>
                    object(Closure)#18 (2) {
                      ["this"]=>
                      *RECURSION*
                      ["parameter"]=>
                      array(1) {
                        ["$msg"]=>
                        string(10) "<required>"
                      }
                    }
                  }
                }
              }
            }
            ["protocolWriter"]=>
            object(LanguageServer\ProtocolStreamWriter)#13 (2) {
              ["output":"LanguageServer\ProtocolStreamWriter":private]=>
              resource(2) of type (stream)
              ["messages":"LanguageServer\ProtocolStreamWriter":private]=>
              array(0) {
              }
            }
            ["idGenerator"]=>
            object(LanguageServer\IdGenerator)#21 (1) {
              ["counter"]=>
              int(1)
            }
          }
        }
        ["workspace"]=>
        object(LanguageServer\Client\Workspace)#25 (2) {
          ["handler":"LanguageServer\Client\Workspace":private]=>
          object(LanguageServer\ClientHandler)#20 (3) {
            ["protocolReader"]=>
            object(LanguageServer\ProtocolStreamReader)#14 (6) {
              ["input":"LanguageServer\ProtocolStreamReader":private]=>
              resource(1) of type (stream)
              ["parsingMode":"LanguageServer\ProtocolStreamReader":private]=>
              int(2)
              ["buffer":"LanguageServer\ProtocolStreamReader":private]=>
              string(1223) "{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":5427,"rootPath":"/data/companywork/Econtract","rootUri":"file:///data/companywork/Econtract","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true}},"textDocument":{"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true}},"hover":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true},"codeAction":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true}}},"trace":"off"}}"
              ["headers":"LanguageServer\ProtocolStreamReader":private]=>
              array(1) {
                ["Content-Length"]=>
                string(4) "1223"
              }
              ["contentLength":"LanguageServer\ProtocolStreamReader":private]=>
              int(1223)
              ["listeners":protected]=>
              array(2) {
                ["close"]=>
                array(3) {
                  [0]=>
                  bool(false)
                  [1]=>
                  array(2) {
                    [0]=>
                    int(100)
                    [1]=>
                    int(100)
                  }
                  [2]=>
                  array(2) {
                    [0]=>
                    object(Closure)#15 (1) {
                      ["this"]=>
                      *RECURSION*
                    }
                    [1]=>
                    object(Closure)#17 (1) {
                      ["this"]=>
                      *RECURSION*
                    }
                  }
                }
                ["message"]=>
                array(3) {
                  [0]=>
                  bool(true)
                  [1]=>
                  array(1) {
                    [0]=>
                    int(100)
                  }
                  [2]=>
                  array(1) {
                    [0]=>
                    object(Closure)#18 (2) {
                      ["this"]=>
                      *RECURSION*
                      ["parameter"]=>
                      array(1) {
                        ["$msg"]=>
                        string(10) "<required>"
                      }
                    }
                  }
                }
              }
            }
            ["protocolWriter"]=>
            object(LanguageServer\ProtocolStreamWriter)#13 (2) {
              ["output":"LanguageServer\ProtocolStreamWriter":private]=>
              resource(2) of type (stream)
              ["messages":"LanguageServer\ProtocolStreamWriter":private]=>
              array(0) {
              }
            }
            ["idGenerator"]=>
            object(LanguageServer\IdGenerator)#21 (1) {
              ["counter"]=>
              int(1)
            }
          }
         ...
duplicate-issues[bot] commented 7 years ago

Hey @banfg56,

We did a quick check and this issue looks very darn similar to

This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:

If not, the maintainers will get to this issue shortly.

Cheers, Your Friendly Neighborhood ProBot

felixfbecker commented 7 years ago

Where does that trace come from? What project are you viewing? How much code does it contain?

banfg56 commented 7 years ago

The trace before comes from PHP debug_backtrace in StubsIndex read function. My Project is a PHP Project, contains about 700 files. PHP7 Version:PHP 7.1.5 (cli) (built: Jun 4 2017 12:37:59) ( NTS )