Skip to content

Commit

Permalink
executor: use any executor if the avoid mask included all of them
Browse files Browse the repository at this point in the history
After 9fc8fe0 ("executor: better handling for hanged test
processes"), yz-executor's responses may reference procids outside of
the [0;procs] range.

If procids are no longer dense on the syz-executor side, we cannot rely
on this check in pkg/rpcserver:
```
	if avoid == (uint64(1)<<runner.procs)-1 {
		avoid = 0
	}
```

Signed-off-by: Andrei Vagin <[email protected]>
  • Loading branch information
avagin authored and dvyukov committed Nov 18, 2024
1 parent e7bb5d6 commit e0aa796
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 13 additions & 1 deletion executor/executor_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,31 @@ class ProcIDPool
constexpr int kNumGoodProcs = 10;
for (int i = 0; i < std::max(num_procs, kNumGoodProcs); i++)
ids_.push_back(i);
mask_ = 0;
}

int Alloc(int old = -1)
{
if (old >= 0)
if (old >= 0) {
mask_ &= ~(1UL << old);
ids_.push_back(old);
}
if (ids_.empty())
fail("out of proc ids");
int id = ids_.front();
ids_.pop_front();
mask_ |= 1UL << id;
return id;
}

uint64 Mask()
{
return mask_;
}

private:
std::deque<int> ids_;
uint64 mask_;

ProcIDPool(const ProcIDPool&) = delete;
ProcIDPool& operator=(const ProcIDPool&) = delete;
Expand Down Expand Up @@ -103,6 +113,8 @@ class Proc
{
if (state_ != State::Started && state_ != State::Idle)
return false;
if (((~msg.avoid) & proc_id_pool_.Mask()) == 0)
msg.avoid = 0;
if (msg.avoid & (1ull << id_))
return false;
if (msg_)
Expand Down
3 changes: 0 additions & 3 deletions pkg/rpcserver/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,6 @@ func (runner *Runner) sendRequest(req *queue.Request) error {
avoid |= uint64(1 << id.Proc)
}
}
if avoid == (uint64(1)<<runner.procs)-1 {
avoid = 0
}
msg := &flatrpc.HostMessage{
Msg: &flatrpc.HostMessages{
Type: flatrpc.HostMessagesRawExecRequest,
Expand Down

0 comments on commit e0aa796

Please sign in to comment.