diff options
author | 2023-11-30 16:22:34 +0000 | |
---|---|---|
committer | 2023-11-30 16:22:34 +0000 | |
commit | eb170003b81504ba6eb85f950c223dc9eaf1cfca (patch) | |
tree | f1f9779e14875faa70f4db85a8cf19100633884d /vendor/codeberg.org/gruf/go-runners | |
parent | [bugfix] always go through status parent dereferencing on isNew, even on data... (diff) | |
download | gotosocial-eb170003b81504ba6eb85f950c223dc9eaf1cfca.tar.xz |
[bugfix] return 400 Bad Request on more cases of malformed AS data (#2399)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-runners')
-rw-r--r-- | vendor/codeberg.org/gruf/go-runners/pool.go | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/vendor/codeberg.org/gruf/go-runners/pool.go b/vendor/codeberg.org/gruf/go-runners/pool.go index 3d9105986..644cde0b9 100644 --- a/vendor/codeberg.org/gruf/go-runners/pool.go +++ b/vendor/codeberg.org/gruf/go-runners/pool.go @@ -221,8 +221,15 @@ func worker_run(ctx context.Context, fns <-chan WorkerFunc) bool { defer func() { // Recover and drop any panic if r := recover(); r != nil { + + // Gather calling func frames. + pcs := make([]uintptr, 10) + n := runtime.Callers(3, pcs) + i := runtime.CallersFrames(pcs[:n]) + c := gatherFrames(i, n) + const msg = "worker_run: recovered panic: %v\n\n%s\n" - fmt.Fprintf(os.Stderr, msg, r, errors.GetCallers(2, 10)) + fmt.Fprintf(os.Stderr, msg, r, c.String()) } }() @@ -243,8 +250,15 @@ func drain_queue(fns <-chan WorkerFunc) bool { defer func() { // Recover and drop any panic if r := recover(); r != nil { - const msg = "drain_queue: recovered panic: %v\n\n%s\n" - fmt.Fprintf(os.Stderr, msg, r, errors.GetCallers(2, 10)) + + // Gather calling func frames. + pcs := make([]uintptr, 10) + n := runtime.Callers(3, pcs) + i := runtime.CallersFrames(pcs[:n]) + c := gatherFrames(i, n) + + const msg = "worker_run: recovered panic: %v\n\n%s\n" + fmt.Fprintf(os.Stderr, msg, r, c.String()) } }() @@ -260,3 +274,19 @@ func drain_queue(fns <-chan WorkerFunc) bool { } } } + +// gatherFrames collates runtime frames from a frame iterator. +func gatherFrames(iter *runtime.Frames, n int) errors.Callers { + if iter == nil { + return nil + } + frames := make([]runtime.Frame, 0, n) + for { + f, ok := iter.Next() + if !ok { + break + } + frames = append(frames, f) + } + return frames +} |