| Issue |
179279
|
| Summary |
lldb MCP spinning 100% CPU
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
peterwaller-arm
|
lldb version 21.1.2
I caught an otherwise paused/quiescent lldb MCP server spinning 100% CPU when I expected it to be idle. `perf record` shows the following stack (below). I don't have specific reproduction steps but essentially I started the server up and used it for a bit and then stopped using it, and whilst it should be idle it is spinning CPU. I think what's happening is that it's not seeing an EOF, but just reading 0 bytes over and over:
https://github.com/llvm/llvm-project/blob/b708aea0bc7127adf4ec643660699c8bcdde1273/lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp#L127-L132
The JSON handler has an empty read check: https://github.com/llvm/llvm-project/blob/eec258dcf38d527cf23cb4c30af63446b1074c8d/lldb/include/lldb/Host/JSONTransport.h#L261-L268
```
- 100.00% 0.00% ocol-server.mcp libc.so.6 [.] thread_start
thread_start
start_thread
execute_native_thread_routine
std::thread::_State_impl<std::thread::_Invoker<std::tuple<lldb_private::mcp::ProtocolServerMCP::Start(lldb_private::ProtocolServer::Connection)::{lambda()#1}> > >::_M_run()
- lldb_private::MainLoopPosix::Run() [clone .localalias]
- 60.39% lldb_private::MainLoopPosix::RunImpl::Poll() [clone .localalias]
- 52.06% ppoll
- 43.68% el0t_64_sync
- el0t_64_sync_handler
- 43.58% el0_svc
- 31.35% do_el0_svc
- el0_svc_common.constprop.0
- invoke_syscall
- 28.57% __arm64_sys_ppoll
- 24.65% do_sys_poll
12.54% fdget
- 5.39% sock_poll
- 4.44% tcp_poll
- 3.21% __pollwait
add_wait_queue
- 3.65% poll_freewait
1.49% remove_wait_queue
1.15% fput
2.01% __pi_memset_generic
0.51% fdget
- 1.72% lldb_private::MainLoopBase::GetNextWakeupTime()
0.63% __GI___pthread_mutex_unlock_usercnt
0.59% pthread_mutex_lock@@GLIBC_2.17
- 35.48% std::_Function_handler<void (lldb_private::MainLoopBase&), lldb_private::mcp::ProtocolServerMCP::AcceptCallback(std::unique_ptr<lldb_private::Socket, std::default_delete<lldb_private::Socket> >)::{lambda(lldb_private::MainLoopBase&)#1}>::_M_invoke(std::_Any_data const&, lldb_private::MainLoopBase&)
- lldb_private::mcp::ProtocolServerMCP::ReadCallback(lldb_private::mcp::ProtocolServerMCP::Client&) [clone .localalias]
- 33.56% lldb_private::Socket::Read(void*, unsigned long&) [clone .localalias]
- 33.02% __libc_recv
- 24.42% el0t_64_sync
- el0t_64_sync_handler
- 24.16% el0_svc
- 11.08% do_el0_svc
- 10.92% el0_svc_common.constprop.0
- 10.46% invoke_syscall
- 8.42% __arm64_sys_recvfrom
- 6.67% __sys_recvfrom
- 3.62% sock_recvmsg
- 3.14% inet_recvmsg
- 2.59% tcp_recvmsg
0.91% tcp_recvmsg_locked
0.56% lock_sock_nested
2.69% fdget
1.06% __pi_memset_generic
- 1.54% lldb_private::MainLoopBase::ProcessCallbacks()
0.68% __GI___pthread_mutex_unlock_usercnt
- 0.84% lldb_private::Status::operator=(lldb_private::Status&&)
lldb_private::Status::Clear() [clone .localalias]
0.54% lldb_private::Status::~Status()
```
/cc potentially interested people @JDevlieghere @ashgti
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs