Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger randomly jumps to ssl.py while stepping through code #1829

Closed
ldorigo opened this issue Feb 10, 2025 · 1 comment
Closed

Debugger randomly jumps to ssl.py while stepping through code #1829

ldorigo opened this issue Feb 10, 2025 · 1 comment
Assignees

Comments

@ldorigo
Copy link

ldorigo commented Feb 10, 2025

Environment data

  • debugpy version: 1.8.8
  • OS and version: MacOS 15.1.1
  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.7
  • Using VS Code or Visual Studio: Vscode 1.96.2 (through Cursor IDE)

Actual behavior

When debugging an async FastAPI application and stepping through code, sometimes the debugger (and editor) randomly jumps specifically to line 1251 of the built-in ssl.py, inside the function:

    def recv_into(self, buffer, nbytes=None, flags=0):
        self._checkClosed()
        if nbytes is None:
            if buffer is not None:
                with memoryview(buffer) as view:
                    nbytes = view.nbytes
                if not nbytes:
                    nbytes = 1024
            else:
                nbytes = 1024
        if self._sslobj is not None:
            if flags != 0:
                raise ValueError(
                  "non-zero flags not allowed in calls to recv_into() on %s" %
                  self.__class__)
            return self.read(nbytes, buffer) # <---- jumps to this line
        else:
            return super().recv_into(buffer, nbytes, flags)

This appears to happen in a thread (not the one whose code I'm stepping through), the stack looks like this:

 File "/Users/ldorigo/.pyenv/versions/3.12.7/lib/python3.12/threading.py", line 1032, in _bootstrap
    self._bootstrap_inner()
  File "/Users/ldorigo/.pyenv/versions/3.12.7/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "/Users/ldorigo/.pyenv/versions/3.12.7/lib/python3.12/threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/langsmith/_internal/_background_thread.py", line 179, in tracing_control_thread_func
    _tracing_thread_handle_batch(
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/langsmith/_internal/_background_thread.py", line 100, in _tracing_thread_handle_batch
    client._multipart_ingest_ops(ops)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/langsmith/client.py", line 1461, in _multipart_ingest_ops
    self._send_multipart_req(acc_multipart)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/langsmith/client.py", line 1571, in _send_multipart_req
    self.request_with_retries(
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/langsmith/client.py", line 712, in request_with_retries
    response = self.session.request(
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/urllib3/connectionpool.py", line 716, in urlopen
    httplib_response = self._make_request(
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/urllib3/connectionpool.py", line 463, in _make_request
    httplib_response = conn.getresponse()
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/sentry_sdk/integrations/stdlib.py", line 131, in getresponse
    rv = real_getresponse(self, *args, **kwargs)
  File "/Users/ldorigo/.pyenv/versions/3.12.7/lib/python3.12/http/client.py", line 1428, in getresponse
    response.begin()
  File "/Users/ldorigo/.pyenv/versions/3.12.7/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
  File "/Users/ldorigo/.pyenv/versions/3.12.7/lib/python3.12/http/client.py", line 292, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/Users/ldorigo/.pyenv/versions/3.12.7/lib/python3.12/socket.py", line 720, in readinto
    return self._sock.recv_into(b)
  File "/Users/ldorigo/.pyenv/versions/3.12.7/lib/python3.12/ssl.py", line 1251, in recv_into
    return self.read(nbytes, buffer)
  File "/Users/ldorigo/.pyenv/versions/3.12.7/lib/python3.12/ssl.py", line 1103, in read
    return self._sslobj.read(len, buffer)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/debugpy/_vendored/pydevd/pydevd.py", line 2181, in do_wait_suspend
    keep_suspended = self._do_wait_suspend(thread, frame, event, arg, trace_suspend_type, from_this_thread, frames_tracker)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/debugpy/_vendored/pydevd/pydevd.py", line 2241, in _do_wait_suspend
    internal_cmd.do_it(self)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 565, in do_it
    self.method(dbg, *self.args, **self.kwargs)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 1214, in internal_evaluate_expression_json
    eval_result = pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=False)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 368, in new_func
    return _run_with_unblock_threads(original_func, py_db, curr_thread, frame, expression, is_exec)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 333, in _run_with_unblock_threads
    return _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 304, in _run_with_interrupt_thread
    return original_func(py_db, frame, expression, is_exec)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 579, in evaluate_expression
    ret = eval_in_context(expression, updated_globals, updated_locals, py_db)
  File "/Users/ldorigo/Library/Caches/pypoetry/virtualenvs/learnwise-chat-97R7xUng-py3.12/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 267, in eval_in_context
    result = eval(compiled, global_vars, local_vars)
  File "<string>", line 1, in <module>

It's similar behaviour to what would happen if I had put a breakpoint on that line of ssl.py and it got hit while I was stepping through code in another thread, except there is no breakpoint.

Expected behavior

Doesn't randomly jump to an unrelated line.

Steps to reproduce:

Really hard, have no idea what triggers this and it's a very complex application. It appears to be related to https://github.com/langchain-ai/langsmith-sdk (as the thread is created and handled by that library), but it doesn't explain the random jumps to the ssl.py file.

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Feb 10, 2025
@rchiodo
Copy link
Contributor

rchiodo commented Feb 10, 2025

Your version of debugpy is 4 versions old. Your problem sounds like a dupe of #1765. Upgrading should fix the problem.

@rchiodo rchiodo closed this as completed Feb 10, 2025
@judej judej removed the needs repro Issue has not been reproduced yet label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants