Add support to dump stacks for ncproxy when requested#1070
Add support to dump stacks for ncproxy when requested#1070katiewasnothere merged 1 commit intomicrosoft:masterfrom
Conversation
internal/guest/bridge/bridge_v2.go
Outdated
|
|
||
| return &prot.DumpStacksResponse{ | ||
| GuestStacks: stacks, | ||
| GuestStacks: string(stacks), |
There was a problem hiding this comment.
nit: string(debug.Stack())
| buf := make([]byte, 4096) | ||
| for { | ||
| buf = buf[:runtime.Stack(buf, true)] | ||
| if len(buf) < cap(buf) { | ||
| break | ||
| } | ||
| buf = make([]byte, 2*len(buf)) | ||
| } |
There was a problem hiding this comment.
Why did we roll our own (if you know haha) that's essentially the exact same besides the buffer that's four times larger? Stack has had that implementation since 1.6 I believe
dcantah
left a comment
There was a problem hiding this comment.
lgtm, assuming we didn't have that debug package for a specific reason that I'm missing. The stdlib comment states that the buffer should be large enough.
| buf = make([]byte, 2*len(buf)) | ||
| } | ||
| resp := &shimdiag.StacksResponse{Stacks: string(buf)} | ||
| stacks := debug.Stack() |
There was a problem hiding this comment.
debug.Stack only returns the stack for the current goroutine, rather than all goroutines (it calls runtime.Stack with all set to false).
There was a problem hiding this comment.
aaaaaaand that's why we had our own 🤦♂️ missed this
There was a problem hiding this comment.
well this is tragic lol I should have looked a little harder at their implementation. I'll add it back.
43b43e5 to
9afe4f3
Compare
cmd/ncproxy/run.go
Outdated
| func etwCallback(sourceID guid.GUID, state etw.ProviderState, level etw.Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr) { | ||
| if state == etw.ProviderStateCaptureState { | ||
| stacks := debug.DumpStacks() | ||
| logrus.WithField("stack", string(stacks)).Info("ncproxy goroutine stack dump") |
There was a problem hiding this comment.
Don't need the string() cast here as stacks is already a string.
Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
9afe4f3 to
35874b7
Compare
Related work items: microsoft#930, microsoft#962, microsoft#1004, microsoft#1008, microsoft#1039, microsoft#1045, microsoft#1046, microsoft#1047, microsoft#1052, microsoft#1053, microsoft#1054, microsoft#1057, microsoft#1058, microsoft#1060, microsoft#1061, microsoft#1063, microsoft#1064, microsoft#1068, microsoft#1069, microsoft#1070, microsoft#1071, microsoft#1074, microsoft#1078, microsoft#1079, microsoft#1081, microsoft#1082, microsoft#1083, microsoft#1084, microsoft#1088, microsoft#1090, microsoft#1091, microsoft#1093, microsoft#1094, microsoft#1096, microsoft#1098, microsoft#1099, microsoft#1102, microsoft#1103, microsoft#1105, microsoft#1106, microsoft#1108, microsoft#1109, microsoft#1115, microsoft#1116, microsoft#1122, microsoft#1123, microsoft#1126
Add an etw callback for dumping ncproxy stacks and revendor the test directory
Signed-off-by: Kathryn Baldauf kabaldau@microsoft.com