You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DAP: loads of a source given by reference which run at once each send a source request; flaky DAPSameNameSourceReferencesSessionTest #2263
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
fix: loads of a DAP source given by reference which run at once ask t…