Skip to content

Debug in python jump in other threads code while debug step by step #1792

Closed

Description

@EnricoBeltramo

Does this issue occur when all extensions are disabled?: Yes/No yes

  • VS Code Version: 1.96.2
  • OS Version: win11

After year that I use vscode without problems to debug python, in latest versions I have problem placing breakpoints in a python multithread program. I have a program with many background threads and now when I set a breakpoint in one of those thread, the ide first break in correct point, after immediately jump in a point in other threads that I'm not interested in, making the debugger unusable. Is a new behaviour? Can be avoided?
Steps to Reproduce:

  1. start a multthread python program
  2. make a breakpoint in one thread
  3. the editor stop in poin, after jump in another poin in another thread

Activity

  1. EnricoBeltramo commented on Dec 24, 2024

    @EnricoBeltramo
    Author

    I verified that this bahaviour is not present with version of python debugger 2024.0.0

  2. added
    needs repro
    on Dec 24, 2024
  3. gijsn commented on Jan 2, 2025

    @gijsn

    I can confirm the same issue with debugpy using the vscode python debugger.
    Using:

    • VSCode 1.96.2 (issue also exists on older versions)
    • Python 3.13.1 (Issue also exists on python 3.12)

    When running the multi-threaded python program with debugger and breakpoint, it shows the following when stopped on the breakpoint:
    Image
    Note, I cannot manually cause this to happen. when I manually step in a file, it will remove the 'Paused on Breakpoint' text and just say 'Paused'

    The program stops on the breakpoint, and then steps once in a secondary thread, causing the 'paused on step' without my interaction. VSCode will show the usual yellow arrow and highlighted line in the file of the second thread (logger). The program is also stopped on the breakpoint (initial stopping cause), but does not open the file to indicate the location. I have to manually open the file with breakpoint, which is also indicating the stopped location (at the breakpoint) with the yellow highlight and arrow once opened.

    As EnricoBeltramo mentions, the issue does not exist on 2024.0.0.

    Thanks

  4. yibudak commented on Jan 4, 2025

    @yibudak

    I'm facing the same problem. The debugger randomly jumps to another thread's line, even though there is no breakpoint. Is there any way to fix this? It makes debugging impossible.

    Edit: I've downgraded debugpy to version 2024.10.0, it works as expected.

  5. rchiodo commented on Jan 6, 2025

    @rchiodo
    Contributor

    This should be a dupe of #1765. If downgrading to 2024.10.0, fixes it, it must be something with the new sys.monitoring support. Another temporary workaround would be to use 3.11 instead of 3.12 as that usess the old code path.

  6. aprisely commented on Jan 14, 2025

    @aprisely

    Also experienced this with python 3.12, selecting the specific debugger version 2024.10.0 fixes the issue and the breakpoint stops on the correct thread, although this means jumping back two versions now so isn't a permanent solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

needs repro

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions