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: Set Value in a thread that is still stopped after another thread continued alone #2185
After a thread other than the stopped one continues alone (continued with allThreadsContinued: false), Set Value
(#2150) refuses in the thread that is still stopped. It says "The program has run since this value was shown: show it
again to set it."
Cause
DAPClient.continued ends the execution epoch of #2150 on every continued event, of any thread. DAPValueModifier
and DAPExpressionModifier send their request only within the epoch of the value's frame
(sendInExecutionEpoch), so every value of the stop counts as out of date.
The question
DAP gives variablesReference and the frame IDs a lifetime of "until the execution resumes", and doesn't say what
happens to the references of the threads that stay stopped when one thread continues alone.
VS Code, on such an event, clears the call stack of that thread only. Its continued handler in debugSession.ts
keeps the other threads' frames and variables usable.
Which adapters reuse or invalidate references on a single-thread continue (lldb-dap, CodeLLDB, GDB, debugpy, Delve,
vscode-js-debug) needs checking in their sources.
How it could be done, once the question is answered
The execution epoch would end only for the threads that continued. Frames would carry their thread (which DAP: Terminate Thread in the context menu of the Frames view #2178 adds
to DAPStackFrame) and the stop's run-state version. sendInExecutionEpoch would then check "this frame's thread
hasn't left its stop", inside the same lock.
Resumes and steps of the session would still end it for all threads, or for the stepping thread of a single-thread
step.
Test
A session test: main stops, the worker continues alone, and Set Value on a local of main's frame sends setVariable
and shows the new value. On the worker's frame, it refuses.
Findings: are a stopped thread's references still valid after another thread continues alone?
It depends on the debug adapter. Below, M is the thread that stays stopped and W is the thread that continues. Everything here is from the adapters' sources, linked below.
Adapter
Can W run while M stays stopped?
References
M's old references after W continues alone
java-debug
Yes, by default: breakpoints suspend only their thread, and continue answers allThreadsContinued: false
Owned by a thread. A single-thread resume drops only that thread's objects, and the counter isn't reset
Valid
debugpy
With stopAllThreadsOnSuspend: false / steppingResumesAllThreads: false
id() of the live object, tracked per suspended thread, and dropped when that thread resumes
Valid
vscode-js-debug
One thread per DAP session
Counters that are never reset
Valid (W is another session)
lldb-dap
No: continued always says all threads
One pool, cleared on every resume, and numbering restarts
Doesn't arise
CodeLLDB
No
Cleared on every resume, then reissued by path
Doesn't arise
Delve
No
Reset at every stop
Doesn't arise
GDB (built-in DAP)
Yes, and it's the only one of the seven that advertises supportsSingleThreadExecutionRequests: singleThread turns on scheduler-locking
Frame IDs, scopes and variable references are cleared by listeners on gdb.events.cont, with no thread filter, and the numbering restarts
Unsafe. They're gone while W runs, and once numbers are handed out again, an old reference of M can point at a different object without an error
VS Code clears only the continuing thread's call stack on continued with allThreadsContinued: false, and every thread's on stopped with allThreadsStopped: true. It never sends singleThread, so it doesn't meet GDB's case. The spec says only that references end "once execution resumes", and I found no DAP issue about single-thread execution.
What this changes in the plan above
Ending the epoch only for the threads that continued is safe with two guards:
A singleThread: true request that LSP4IJ sends ends the epoch for every thread. This is what GDB needs, and it's the adapter that gets those requests. The per-thread end applies only when the adapter itself runs one thread: a continued event with allThreadsContinued: false (java-debug, debugpy, js-debug), or a continue response with false to a request without singleThread (java-debug). So "the stepping thread of a single-thread step" above becomes "every thread".
A stopped event with allThreadsStopped: true ends the epoch for every thread, even for a thread that never left its stop, as VS Code clears every call stack there. That covers the adapters that renumber at every stop.
Comparing the IDs of a new stackTrace isn't a safe check, since GDB, Delve and lldb-dap reuse the same numbers.
Activity
lagergren commentedon Nov 24, 2026
Findings: are a stopped thread's references still valid after another thread continues alone?
It depends on the debug adapter. Below, M is the thread that stays stopped and W is the thread that continues. Everything here is from the adapters' sources, linked below.
continueanswersallThreadsContinued: falsestopAllThreadsOnSuspend: false/steppingResumesAllThreads: falseid()of the live object, tracked per suspended thread, and dropped when that thread resumescontinuedalways says all threadssupportsSingleThreadExecutionRequests:singleThreadturns on scheduler-lockinggdb.events.cont, with no thread filter, and the numbering restartsVS Code clears only the continuing thread's call stack on
continuedwithallThreadsContinued: false, and every thread's onstoppedwithallThreadsStopped: true. It never sendssingleThread, so it doesn't meet GDB's case. The spec says only that references end "once execution resumes", and I found no DAP issue about single-thread execution.What this changes in the plan above
Ending the epoch only for the threads that continued is safe with two guards:
singleThread: truerequest that LSP4IJ sends ends the epoch for every thread. This is what GDB needs, and it's the adapter that gets those requests. The per-thread end applies only when the adapter itself runs one thread: acontinuedevent withallThreadsContinued: false(java-debug, debugpy, js-debug), or acontinueresponse withfalseto a request withoutsingleThread(java-debug). So "the stepping thread of a single-thread step" above becomes "every thread".stoppedevent withallThreadsStopped: trueends the epoch for every thread, even for a thread that never left its stop, as VS Code clears every call stack there. That covers the adapters that renumber at every stop.Comparing the IDs of a new
stackTraceisn't a safe check, since GDB, Delve and lldb-dap reuse the same numbers.Sources
The implementation waits for #2181, and for #2178's thread on
DAPStackFrame.fix: Set Value works in a DAP thread which is still stopped after ano…