未验证 提交 3941af1d 编写于 作者: S Suzy Mueller 提交者: GitHub

service/dap: limit the number of goroutines to return from a threads request (#2595)

This adds a cap and a log message if there are many goroutines. This will help
prevent the debugger from freezing, but does not yet address making sure the
interesting goroutines are the ones that are returned.

Updates golang/vscode-go#129
上级 658d36cb
......@@ -191,6 +191,8 @@ const (
// what is presented. A common use case of a call injection is to
// stringify complex data conveniently.
maxStringLenInCallRetVars = 1 << 10 // 1024
// Max number of goroutines that we will return.
maxGoroutines = 1 << 10
)
// NewServer creates a new DAP Server. It takes an opened Listener
......@@ -1456,7 +1458,7 @@ func (s *Server) onThreadsRequest(request *dap.ThreadsRequest) {
return
}
gs, _, err := s.debugger.Goroutines(0, 0)
gs, next, err := s.debugger.Goroutines(0, maxGoroutines)
if err != nil {
switch err.(type) {
case proc.ErrProcessExited:
......@@ -1469,6 +1471,10 @@ func (s *Server) onThreadsRequest(request *dap.ThreadsRequest) {
return
}
if next >= 0 {
s.logToConsole(fmt.Sprintf("too many goroutines, only loaded %d", len(gs)))
}
threads := make([]dap.Thread, len(gs))
if len(threads) == 0 {
// Depending on the debug session stage, goroutines information
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册