Skip to content

DAP: Set Value in a thread that is still stopped after another thread continued alone #2185

Done

Description

@lagergren

What happens

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

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.

Related: #2150, #2176, #2181, #2106.

Activity

  1. added this to the 0.30.2 milestone on Nov 24, 2026
  2. added
    enhancement
    question
    dap
    on Nov 24, 2026
  3. lagergren commented on Nov 24, 2026

    @lagergren
    CollaboratorAuthor

    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:

    1. 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".
    2. 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.

    Sources

    The implementation waits for #2181, and for #2178's thread on DAPStackFrame.

  4. added a commit that references this issue on Nov 25, 2026
    a3d6dd0
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

    dapenhancementquestion

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions