Bug 32133 - gdb.error: Frame is invalid.
Summary: gdb.error: Frame is invalid.
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: dap (show other bugs)
Version: 15.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-02 09:31 UTC by Oleg Tolmatcev
Modified: 2024-09-23 18:07 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2024-09-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Tolmatcev 2024-09-02 09:31:45 UTC
I use gdb 15.1 with this DAP debugger extension on Windows https://github.com/oltolm/vscode-gdb. I get the "gdb.error: Frame is invalid." error. This happens because the frame was created on one thread but is used on another.

This is the backtrace from the "scopes" request. The same happens for the "variables" request.

READ: <<<{"command": "scopes", "arguments": {"frameId": 11}, "type": "request", "seq": 29}>>>
Traceback (most recent call last):
  File "C:\msys64/mingw64/share/gdb/python\gdb\dap\server.py", line 157, in _handle_command
    body = _commands[params["command"]](**args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\msys64/mingw64/share/gdb/python\gdb\dap\server.py", line 300, in check
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\msys64/mingw64/share/gdb/python\gdb\dap\server.py", line 360, in sync_call
    return send_gdb_with_response(lambda: func(**args))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\msys64/mingw64/share/gdb/python\gdb\dap\server.py", line 514, in send_gdb_with_response
    raise val
  File "C:\msys64/mingw64/share/gdb/python\gdb\dap\server.py", line 470, in __call__
    val = self.fn()
          ^^^^^^^^^
  File "C:\msys64/mingw64/share/gdb/python\gdb\dap\server.py", line 360, in <lambda>
    return send_gdb_with_response(lambda: func(**args))
                                          ^^^^^^^^^^^^
  File "C:\msys64/mingw64/share/gdb/python\gdb\dap\startup.py", line 113, in ensure_gdb_thread
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\msys64/mingw64/share/gdb/python\gdb\dap\typecheck.py", line 86, in check_arguments
    return func(**kwargs)
           ^^^^^^^^^^^^^^
  File "C:\msys64/mingw64/share/gdb/python\gdb\dap\scopes.py", line 151, in scopes
    args = tuple(frame.frame_args() or ())
                 ^^^^^^^^^^^^^^^^^^
  File "C:\msys64/mingw64/share/gdb/python\gdb\FrameDecorator.py", line 102, in frame_args
    if self.__is_limited_frame(frame):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\msys64/mingw64/share/gdb/python\gdb\FrameDecorator.py", line 33, in __is_limited_frame
    sal = frame.find_sal()
          ^^^^^^^^^^^^^^^^
gdb.error: Frame is invalid.
WROTE: <<<{"request_seq": 29, "type": "response", "command": "scopes", "success": false, "message": "Frame is invalid."}>>>

I have a patch which fixes this problem for the "scopes" and "variables" requests. I am building a map from scope to thread or from variable to thread and switch to the correct thread in the request. I am not sure it is the best way but I can submit them.
Comment 1 Tom Tromey 2024-09-04 12:22:15 UTC
Big oversight!  Thanks for finding this.
I suspect expression evaluation will also need this fix.
Comment 2 Oleg Tolmatcev 2024-09-23 18:07:34 UTC
I posted a patch (https://sourceware.org/pipermail/gdb-patches/2024-September/211566.html) to the mailing list. Is it possible to get it in GDB 15.2?