Skip to content

DAP: loads of a source given by reference which run at once each send a source request; flaky DAPSameNameSourceReferencesSessionTest #2263

Done

Description

@lagergren

On CI (Test, ubuntu-latest, 2025.3), DAPSameNameSourceReferencesSessionTest > testAFrameWhichIsNotShownLoadsItsTextInItsOwnFile failed with expected:<[5, 9]> but was:<[5, 5, 9]> at line 223. The debug adapter got the source request for the first frame's reference twice. The test and the feature came with #2204.

Cause

A race in LSP4IJ:

  • DAPStackFrame.getSourcePosition() creates its position lazily, without a lock, and creating a DAPSourceReferencePosition sends source.
  • The debug session publishes the stop (isSuspended(), the top frame) before it asks for the top frame's position on the DAP event thread. So the EDT (the Frames view, or the user showing the frame) and other threads ask for the same frame's position at once, and each one that finds none yet starts a load.
  • Also, a frame skips the load only once its file holds the text, which happens only after the first answer is stored. Until then, two frames of one source, a later frame, Jump to Source or Loaded Sources each send their own request.

A real debug adapter gets duplicate source requests. The text isn't written twice.

To reproduce

  • With a probe: hold the first background caller of the top frame's getSourcePosition() after its null check until the EDT has asked too. testAFrameWhichIsNotShownLoadsItsTextInItsOwnFile and testEachFrameShowsTheTextOfItsOwnSource then fail every time with [5, 5, 9].
  • Without a probe: let the debug adapter hold its answer to source, and ask for the position of two DAPStackFrames of a source whose file doesn't hold its text. Two requests are sent.

Activity

  1. added this to the 0.30.2 milestone on Nov 25, 2026
  2. added
    bug
    on Nov 25, 2026
  3. added a commit that references this issue on Nov 25, 2026
    a83b369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions