microsoft / debugpy

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

Troubles when expanding self object during debug in constructor #1609

Open ibobak opened 2 months ago

ibobak commented 2 months ago

Type: Bug

Behaviour

When I am debugging a constructor of the object and in that debug session I am trying to expand "self" in the watch window, the python process crashes,

Steps to reproduce:

  1. install anaconda
  2. create a new environment
  3. pip install catboost
  4. create a new notebook, make a single cell with this code
    
    from catboost import CatBoostRegressor, Pool
    # Initialize data

train_data = [[1, 4, 5, 6], [4, 5, 6, 7], [30, 40, 50, 60]]

eval_data = [[2, 4, 6, 8], [1, 4, 50, 60]]

train_labels = [10, 20, 30]

p = Pool(data=train_data, label=train_labels)

Initialize CatBoostRegressor

model = CatBoostRegressor(iterations=2, learning_rate=1, depth=2)

Fit model

model.fit(train_data, train_labels)

Get predictions

preds = model.predict(eval_data)

5. Put a brakpoint on line 

p = Pool(data=train_data, label=train_labels)


6. "Go to definition" for Pool,   you will be redirected to Pool class,  inside this class put a breakpoint on the firtst line

with log_fixup(log_cout, log_cerr):

7. Debug this cell.  
8. As soon as your debugging line is this  "with log_fixup(log_cout, log_cerr)",  open the "self" object 
![image](https://github.com/microsoft/vscode-python-debugger/assets/8807043/e8ec90ec-c63d-45d3-b769-578394a00221)
![image](https://github.com/microsoft/vscode-python-debugger/assets/8807043/e5fb82aa-7d87-49a1-8943-e4248cc1d536)

<!--
**After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation.
-->

<!-- **NOTE**: Please do provide logs from the Python and Python Debugger Output panel. -->
# Diagnostic data
<details>

<summary><code>launch.json</code> configuration
</summary>

<p>

XXX


</p>
</details>

<details>

<summary>Output for <code>Python</code> in the <code>Output</code> panel (<code>View</code>→<code>Output</code>, change the drop-down the upper-right of the <code>Output</code> panel to <code>Python</code>)
</summary>

<p>

XXX


</p>
</details>

<details>

<summary>Output for <code>Python Debugger</code> in the <code>Output</code> panel (<code>View</code>→<code>Output</code>, change the drop-down the upper-right of the <code>Output</code> panel to <code>Python Debugger</code>)
</summary>

<p>

XXX


</p>
</details>

Extension version: 2024.6.0
VS Code version: Code 1.90.2 (5437499feb04f7a586f677b155b039bc2b3669eb, 2024-06-18T22:33:48.698Z)
OS version: Linux x64 6.4.6-060406-generic
Modes:

-   Python version (& distribution if applicable, e.g. Anaconda): 3.11.9
-   Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Xeon(R) CPU E5-2696 v4 @ 2.20GHz (88 x 2706)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: disabled_off<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>video_decode: enabled<br>video_encode: disabled_software<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: disabled_off|
|Load (avg)|17, 21, 14|
|Memory (System)|251.76GB (41.57GB free)|
|Process Argv|--crash-reporter-id 27d42247-63fb-4d9e-9cb0-87d9974843dc|
|Screen Reader|no|
|VM|50%|
|DESKTOP_SESSION|ubuntu-xorg|
|XDG_CURRENT_DESKTOP|Unity|
|XDG_SESSION_DESKTOP|ubuntu-xorg|
|XDG_SESSION_TYPE|x11|
</details><details>
<summary>A/B Experiments</summary>

vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 2i9eh265:30646982 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 jchc7451:31067544 chatpanelt:31048053 dsvsc021:30996838 9c06g630:31013171 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 2f103344:31071589 legacy_priority:31077528



</details>

<!-- generated by issue reporter -->
rchiodo commented 2 months ago

Thanks for the issue. I can repro without a notebook too. Retrieving the value for cat_features is causing pydevd to crash.

rchiodo commented 2 months ago

Here's the logs from my crash: debugpy.server-11776.zip

ibobak commented 2 months ago

Rich, if you tell me how to get the logs, next time I will know how to do this and will attach them.

rchiodo commented 2 months ago

I'm actually not sure how to do it when jupyter debugging, but if you're using a launch.json (for a python file), it's a setting:

        {
            "name": "Python Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "logToFile": true, // This setting
            "justMyCode": false
        }

It writes the logs to where the python debugger extension is installed. In my case, that's here:

C:\Users\rchiodo.vscode\extensions\ms-python.debugpy-2024.7.11591013-win32-x64