Improvements to stuck task tool

Use function names as line ID (path+line may include registers that make it
non-unique). Sort larger stacks at the top. This is useful to spot unique
stacks that are likely the ones causing the deadlock.

PiperOrigin-RevId: 810562912
This commit is contained in:
Fabricio Voznika
2025-09-23 13:39:42 -07:00
committed by gVisor bot
parent baacd340c6
commit efc1bd1884
2 changed files with 13 additions and 5 deletions
+1 -3
View File
@@ -8,7 +8,5 @@ package(
go_binary(
name = "stucktasks",
srcs = ["stucktasks.go"],
deps = [
"//runsc/flag",
],
deps = ["//runsc/flag"],
)
+12 -2
View File
@@ -134,7 +134,11 @@ func analyzeStackDump(scanner *bufio.Scanner, out io.Writer, stuckIds map[uint]s
sorted = append(sorted, c)
}
sort.Slice(sorted, func(i, j int) bool {
// Reverse sort
// Sort with the most occurring stacks first, then start with the longest stacks (likely
// to be the more relevant for deadlocks).
if sorted[i].count == sorted[j].count {
return len(sorted[i].stack.lines) > len(sorted[j].stack.lines)
}
return sorted[i].count > sorted[j].count
})
@@ -210,7 +214,13 @@ func parseBlock(block []string) (*stack, error) {
var signature string
for i, line := range block[1:] {
if i%2 == 1 {
// Only look at function names. Skip odd lines that contain file names.
if i%2 == 0 {
// Use the full function name, but ignore argument values.
idx := strings.LastIndex(line, "(")
if idx != -1 {
line = line[:idx]
}
signature += line + "\n"
}
}