microsoft / debugpy

An implementation of the Debug Adapter Protocol for Python
https://pypi.org/project/debugpy/
Other
1.86k stars 138 forks source link

debugpy >=1.8.6 errors out when used with numba #1719

Open hoxbro opened 2 weeks ago

hoxbro commented 2 weeks ago

Before creating a new issue, please check the FAQ to see if your question is answered there.

Environment data

Actual behavior

Debugpy errors out when used with Numba

Expected behavior

The code runs as it did with debugpy 1.8.5

Steps to reproduce:

Run the following code in with a breakpoint

import numba as nb

@nb.njit
def nb_sum(arr):
    xs = 0
    for x in arr:
        xs += x
    return xs

res = nb_sum([1, 2])
print("Set breakpoint here")

Image

Traceback (most recent call last):
  File "_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx", line 555, in _pydevd_sys_monitoring_cython._get_func_code_info
KeyError: (3, '/home/shh/projects/holoviz/repos/holoviews/example3.py', <code object nb_sum at 0x7a127fc59110, file "/home/shh/projects/holoviz/repos/holoviews/example3.py", line 3>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/shh/miniconda3/envs/holoviz/lib/python3.12/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shh/miniconda3/envs/holoviz/lib/python3.12/runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "/home/shh/.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in <module>
    cli.main()
  File "/home/shh/.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 501, in main
    run()
  File "/home/shh/.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 351, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/home/shh/.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 310, in run_path
    return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/shh/.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 127, in _run_module_code
    _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
  File "/home/shh/.vscode/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 118, in _run_code
    exec(code, run_globals)
  File "/home/shh/projects/holoviz/repos/holoviews/example3.py", line 10, in <module>
    res = nb_sum([1,2])
          ^^^^^^^^^^^^^
  File "<stringsource>", line 69, in cfunc.to_py.__Pyx_CFunc_893235__29_pydevd_sys_monitoring_cython_object__lParen__etc_to_py_4code_18instruction_offset.wrap
  File "_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx", line 1662, in _pydevd_sys_monitoring_cython._start_method_event
  File "_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx", line 562, in _pydevd_sys_monitoring_cython._get_func_code_info
AssertionError: <code object <module> at 0x7a127fc8d230, file "/home/shh/projects/holoviz/repos/holoviews/example3.py", line 1> != <code object nb_sum at 0x7a127fc59110, file "/home/shh/projects/holoviz/repos/holoviews/example3.py", line 3>
hoxbro commented 9 hours ago

It still seems to error out on 1.8.9