Skip to content

Deadlock in registerNewDebugSession threads #22

@alt-romes

Description

@alt-romes

Dear @dmjio,

Me and @mpickering have been implementing a debugger for GHC and we started using the dap library for the DAP part of the debugger.
However, we ran into a nasty deadlock while doing something seemingly standard in the debugger threads that are launched by registerNewDebugSession.

We had something that looked like

  (readDebuggerOutput, writeDebuggerOutput) <- liftIO P.createPipe
  registerNewDebugSession (maybe "debug-session" T.pack __sessionId) DAS{..}
    [ debuggerThread ... writeDebuggerOutput
    , outputEventsThread readDebuggerOutput
    ]

And this resulted in a deadlock within dap outlined as:

  1. Initialisation starts, starts writing to a pipe
  2. Worker thread tries to output things from the pipe, but can't because that requires taking a lock on the MVar
  3. Step 1 blocks because the pipe gets full
  4. Step 2 blocks, since it is waiting for step 1 to finish

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