mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[bugfix] return 400 Bad Request on more cases of malformed AS data (#2399)
This commit is contained in:
36
vendor/codeberg.org/gruf/go-runners/pool.go
generated
vendored
36
vendor/codeberg.org/gruf/go-runners/pool.go
generated
vendored
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user