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

lldb-mi hangs on M1 macOS when creating variable #101

Open
LimingFang opened this issue Jun 23, 2022 · 12 comments
Open

lldb-mi hangs on M1 macOS when creating variable #101

LimingFang opened this issue Jun 23, 2022 · 12 comments

Comments

@LimingFang
Copy link

LimingFang commented Jun 23, 2022

Environment

  • OS and version: macOS Monterey 12.4
  • VS Code: 1.68.0
  • C/C++ extension: 1.11.0
  • OS and version of remote machine (if applicable): no
  • GDB / LLDB version: 13.0.1

Bug Summary and Steps to Reproduce

Bug Summary: When debugging some code(for example, leveldb test code), sometimes the debug can't go on.

Steps to reproduce:

  1. Clone leveldb and add main.cpp

image

4. Debug this executable, when entering DB::Open:

image

then I was stuck in `*dbptr = nullptr;` where there's 4 lldb-mi process and in the right panel(variable),there is a circle spinning.

Debugger Configurations

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "cppdbg",
      "request": "launch",
      "name": "Debug main test",
      "program": "${workspaceFolder}/build/main_test",
      "args": [],
      "MIMode": "lldb",
      "cwd": "${workspaceFolder}",
      "MIMode": "lldb",
      "miDebuggerPath": "/Users/fangliming/Documents/GitHub/collections/lldb-mi/src/lldb-mi",
    }
  ]

lldb-mi version

image

Debugger Logs

log link

Additional Information

  • lldb-mi won't exit when stop debugging.
  • CodeLLDB extension works fine on my Mac.

outro

From the logs, it looks like the debugger is hanging on creating the variable edit.

-1034-var-create - - "edit" --thread 1 --frame 0

Why it is hanging on creating the VersionEdit edit variable.

@LimingFang LimingFang changed the title lldb-mi hangs on M1 macOS lldb-mi hangs on M1 macOS when creating variable Jun 23, 2022
@H-G-Hristov
Copy link

H-G-Hristov commented Sep 2, 2022

I seem to have the same issue when I try to debug a Google Test UnitTest with the TestMate C++ extension.

There are more details here:

microsoft/vscode-cpptools#9831

I hit the issue with a code like this. In this context it is reproducible 100%. In other context there is no issue.

    struct KeepAlive
    {
        /**
         * @brief `KeepAlive` subkeys.
         *
         */
        enum class Subkey
        {
            /// Subkey `AfterInitialDemand` - delaying the start.
            AfterInitialDemand,
            /// Subkey `Crashed` - depending on crashes.
            Crashed,
            /// Subkey `NetworkState` - depending on network availability.
            NetworkState,
            /// Subkey `OtherJobEnabled` - depending on other jobs.
            OtherJobEnabled,
            /// Subkey `PathState` - depending on the existence of a path.
            PathState,
            /// Subkey `SuccessfulExit` - depending on the last exit status.
            SuccessfulExit,
        };

        /**
         * @brief `KeepAlive` subkey value types.
         *
         */
        struct SubkeyValueType
        {
            /// Subkey `AfterInitialDemand` - delaying the start.
            using AfterInitialDemand = std::map<std::string, bool>;
            /// Subkey `Crashed` - depending on crashes.
            using Crashed = bool;
            /// Subkey `NetworkState` - depending on network availability.
            using NetworkState = bool;
            /// Subkey `OtherJobEnabled` - depending on other jobs.
            using OtherJobEnabled = std::map<std::string, bool>;
            /// Subkey `PathState` - depending on the existence of a path.
            using PathState = std::map<std::string, bool>;
            /// Subkey `SuccessfulExit` - depending on the last exit status.
            using SuccessfulExit = bool;
        };

        /**
         * @brief A `variant` of `KeepAlive` subkey value types.
         *
         */
        using SubkeyType = ::boost::variant2::variant<
            KeepAlive::SubkeyValueType::AfterInitialDemand,
            KeepAlive::SubkeyValueType::Crashed,
            KeepAlive::SubkeyValueType::NetworkState,
            KeepAlive::SubkeyValueType::OtherJobEnabled,
            KeepAlive::SubkeyValueType::PathState,
            KeepAlive::SubkeyValueType::SuccessfulExit>;
    };

tl::optional<
    ::boost::variant2::variant<bool, std::map<ILaunchdPlist::KeepAlive::Subkey, ILaunchdPlist::KeepAlive::SubkeyType>>>
LaunchdPlist::GetKeepAlive() const noexcept
{
...
}

TEST_F(LaunchdPlistTest, GetKeepAliveBool)
{
    // Binary plist

    auto valueOpt = LaunchdPlistTest::GetValidBinaryPlist()->GetKeepAlive();
    EXPECT_TRUE(valueOpt.has_value());

Here it hangs:
Screenshot 2022-09-02 at 9 26 03

@H-G-Hristov
Copy link

If I stop debugging the lldb-mi process stays running at 100% CPU.

Screenshot 2022-09-02 at 9 28 12

@H-G-Hristov
Copy link

After several runs I have multiple lldb-mi instances:

Screenshot 2022-09-02 at 9 29 58

@H-G-Hristov
Copy link

H-G-Hristov commented Sep 9, 2022

Same here:
#96 #89
VSCode is rendered useless because of this in a complex scenario of C++ templates, abstract classes and Google Test.

I can confirm now that this issue happened to me on Intel macOS BigSur but it is very, very common and reproducible on M1 in the above scenario.

@hackroid
Copy link

related microsoft/vscode-cpptools/issues/10176

@donangel
Copy link

Same issue here.

@alexolog
Copy link

alexolog commented Apr 5, 2023

Any chance of this being looked at?

@garfieldnate
Copy link

Is this perhaps related to microsoft/vscode-cpptools#7240 (comment)? @shiretu posted his workaround there. Further comment:

This is truly a problem with the lldb. See my patch above. lldb is out-of-bounds-ing on walking uninitialized variables with garbage values on things like internal counters and sizes. My quick yet brutal fix is to limit these things to 64.

Unfortunately, VSCode tries to render all local variables in the current scope. And when it reaches one of those not-yet-initialized vars, it behaves like that.

@pangdaxing23
Copy link

I can confirm this is also happening on Monterey on Intel Mac.

@sunshaoce
Copy link
Collaborator

We need a programmer to solve this bug : )

@H-G-Hristov
Copy link

@sunshaoce This is getting a major issue. CodeLLDB also stopped working recently.

@sunshaoce
Copy link
Collaborator

microsoft/vscode-cpptools#7240
Here seems to be a feasible solution, can any Mac users help test it out?

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

8 participants