queue

package
v0.0.0-...-ef44b75 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StatNoExecRequests = stat.New("no exec requests",
		"Number of times fuzzer was stalled with no exec requests", stat.Rate{})
	StatNoExecDuration = stat.New("no exec duration",
		"Total duration fuzzer was stalled with no exec requests (ns/sec)", stat.Rate{})
	StatExecBufferTooSmall = stat.New("buffer too small",
		"Program serialization overflowed exec buffer", stat.NoGraph)
)

Common stats related to fuzzing that are updated/read by different parts of the system.

View Source
var ErrRequestAborted = errors.New("context closed while waiting the result")

Functions

This section is empty.

Types

type Deduplicator

type Deduplicator struct {
	// contains filtered or unexported fields
}

Deduplicator() keeps track of the previously run requests to avoid re-running them.

func (*Deduplicator) Next

func (d *Deduplicator) Next() *Request

type Distributor

type Distributor struct {
	// contains filtered or unexported fields
}

Distributor distributes requests to different VMs during input triage (allows to avoid already used VMs).

func Distribute

func Distribute(source Source) *Distributor

func (*Distributor) Next

func (dist *Distributor) Next(vm int) *Request

Next returns the next request to execute on the given vm.

type DoneCallback

type DoneCallback func(*Request, *Result) bool

type DynamicOrderer

type DynamicOrderer struct {
	// contains filtered or unexported fields
}

func DynamicOrder

func DynamicOrder() *DynamicOrderer

DynamicOrder() can be used to form nested queues dynamically. That is, if q1 := pq.Append() q2 := pq.Append() All elements added via q2.Submit() will always have a *lower* priority than all elements added via q1.Submit().

func (*DynamicOrderer) Append

func (do *DynamicOrderer) Append() Executor

func (*DynamicOrderer) Next

func (do *DynamicOrderer) Next() *Request

type DynamicSourceCtl

type DynamicSourceCtl struct {
	// contains filtered or unexported fields
}

func DynamicSource

func DynamicSource(source Source) *DynamicSourceCtl

DynamicSource is assumed never to point to nil.

func (*DynamicSourceCtl) Next

func (ds *DynamicSourceCtl) Next() *Request

func (*DynamicSourceCtl) Store

func (ds *DynamicSourceCtl) Store(source Source)

type Executor

type Executor interface {
	Submit(req *Request)
}

Executor describes the interface wanted by the producers of requests. After a Request is submitted, it's expected that the consumer will eventually take it and report the execution result via Done().

type ExecutorID

type ExecutorID struct {
	VM   int
	Proc int
}

type PlainQueue

type PlainQueue struct {
	// contains filtered or unexported fields
}

PlainQueue is a straighforward thread-safe Request queue implementation.

func Plain

func Plain() *PlainQueue

func (*PlainQueue) Len

func (pq *PlainQueue) Len() int

func (*PlainQueue) Next

func (pq *PlainQueue) Next() *Request

func (*PlainQueue) Submit

func (pq *PlainQueue) Submit(req *Request)

type RandomQueue

type RandomQueue struct {
	// contains filtered or unexported fields
}

RandomQueue holds up to |size| elements. Next() evicts a random one. On Submit(), if the queue is full, a random element is replaced.

func NewRandomQueue

func NewRandomQueue(size int, rnd *rand.Rand) *RandomQueue

func (*RandomQueue) Next

func (rq *RandomQueue) Next() *Request

func (*RandomQueue) Submit

func (rq *RandomQueue) Submit(req *Request)

type Request

type Request struct {
	// Type of the request.
	// RequestTypeProgram executes Prog, and is used by most requests (also the default zero value).
	// RequestTypeBinary executes binary with file name stored in Data.
	// RequestTypeGlob expands glob pattern stored in Data.
	Type        flatrpc.RequestType
	ExecOpts    flatrpc.ExecOpts
	Prog        *prog.Prog // for RequestTypeProgram
	BinaryFile  string     // for RequestTypeBinary
	GlobPattern string     // for 	RequestTypeGlob

	// Return all signal for these calls instead of new signal.
	ReturnAllSignal []int
	ReturnError     bool
	ReturnOutput    bool

	// This stat will be incremented on request completion.
	Stat *stat.Val

	// Important requests will be retried even from crashed VMs.
	Important bool

	// Avoid specifies set of executors that are preferable to avoid when executing this request.
	// The restriction is soft since there can be only one executor at all or available right now.
	Avoid []ExecutorID
	// contains filtered or unexported fields
}

func (*Request) Done

func (r *Request) Done(res *Result)

func (*Request) OnDone

func (r *Request) OnDone(cb DoneCallback)

func (*Request) Risky

func (r *Request) Risky() bool

Risky() returns true if there's a substantial risk of the input crashing the VM.

func (*Request) Validate

func (r *Request) Validate() error

func (*Request) Wait

func (r *Request) Wait(ctx context.Context) *Result

Wait() blocks until we have the result.

type Result

type Result struct {
	Info     *flatrpc.ProgInfo
	Executor ExecutorID
	Output   []byte
	Status   Status
	Err      error // More details in case of ExecFailure.
}

func (*Result) GlobFiles

func (r *Result) GlobFiles() []string

Globs returns result of RequestTypeGlob.

func (*Result) Stop

func (r *Result) Stop() bool

type Source

type Source interface {
	Next() *Request
}

Source describes the interface wanted by the consumers of requests.

func Alternate

func Alternate(base Source, nth int) Source

Alternate proxies base, but returns nil every nth Next() call.

func Callback

func Callback(cb func() *Request) Source

Callback produces a source that calls the callback to serve every Next() request.

func Deduplicate

func Deduplicate(source Source) Source

func DefaultOpts

func DefaultOpts(source Source, opts flatrpc.ExecOpts) Source

DefaultOpts applies opts to all requests in source.

func Order

func Order(sources ...Source) Source

func Retry

func Retry(base Source) Source

Retry adds a layer that resends results with Status=Restarted.

func Tee

func Tee(src Source, queue Executor) Source

type Status

type Status int
const (
	Success     Status = iota
	ExecFailure        // For e.g. serialization errors.
	Crashed            // The VM crashed holding the request.
	Restarted          // The VM was restarted holding the request.
	Hanged             // The program has hanged (can't be killed/waited).
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL