Skip to content

Inifinite recursion in logger #447

Open
@kokobd

Description

@kokobd

This was originally found in haskell/haskell-language-server#3072

In lsp, there is a debug log, printing response body:

-- We need to make sure we only send over the content of the message,
-- and no other tags/wrapper stuff
let str = J.encode msg
let out = BSL.concat
[ TL.encodeUtf8 $ TL.pack $ "Content-Length: " ++ show (BSL.length str)
, BSL.fromStrict _TWO_CRLF
, str ]
clientOut out
logger <& SendMsg (TL.decodeUtf8 str) `WithSeverity` Debug

And in HLS, our logger sends a copy of log to LSP client:
https://github.com/haskell/haskell-language-server/blob/347a7187f20242540926b9927c59a45b18798c67/exe/Main.hs#L72-L82

Then it goes into infinite recursion. A lot of logs like below are produced, and finally OOM on a machine with 64GB RAM.

graph

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions