aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/fuzzer/queue/queue.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-01-30 11:49:34 +0100
committerAleksandr Nogikh <nogikh@google.com>2025-01-30 11:03:14 +0000
commite961d16c3e35fd78acdfaf5531fc1c1365c24a97 (patch)
tree37f72c1514b9f3938983da79380a3b3f8bbaf485 /pkg/fuzzer/queue/queue.go
parent9c8ab8458ec658aa3007c0e8c1695907c8d8c39f (diff)
all: clarify the error in case of ExecFailure
Whenever the status is set, also include the reason. It should help easier debug execution and machine check time problems.
Diffstat (limited to 'pkg/fuzzer/queue/queue.go')
-rw-r--r--pkg/fuzzer/queue/queue.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/fuzzer/queue/queue.go b/pkg/fuzzer/queue/queue.go
index 58c9f1561..6e17225e2 100644
--- a/pkg/fuzzer/queue/queue.go
+++ b/pkg/fuzzer/queue/queue.go
@@ -7,6 +7,7 @@ import (
"bytes"
"context"
"encoding/gob"
+ "errors"
"fmt"
"math/rand"
"strings"
@@ -99,12 +100,14 @@ func (r *Request) Done(res *Result) {
close(r.done)
}
+var errContextAborted = errors.New("context closed while waiting the result")
+
// Wait() blocks until we have the result.
func (r *Request) Wait(ctx context.Context) *Result {
r.initChannel()
select {
case <-ctx.Done():
- return &Result{Status: ExecFailure}
+ return &Result{Status: ExecFailure, Err: errContextAborted}
case <-r.done:
return r.result
}
@@ -537,6 +540,8 @@ func (rq *RandomQueue) Next() *Request {
return item
}
+var errEvictedFromQueue = errors.New("evicted from the random queue")
+
func (rq *RandomQueue) Submit(req *Request) {
rq.mu.Lock()
defer rq.mu.Unlock()
@@ -545,7 +550,10 @@ func (rq *RandomQueue) Submit(req *Request) {
} else {
pos := rq.rnd.Intn(rq.maxSize + 1)
if pos < len(rq.queue) {
- rq.queue[pos].Done(&Result{Status: ExecFailure})
+ rq.queue[pos].Done(&Result{
+ Status: ExecFailure,
+ Err: errEvictedFromQueue,
+ })
rq.queue[pos] = req
}
}