Fuzzer Not Detecting Incorrect Allocation

Open
#191 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
compilers

Research direction

Start by running the tests in src/fastalloc/tests.rs at the referenced commit and inspect how branch instruction operands are represented and checked. Compare the two provided examples, then determine whether branch operands should be disallowed or included in fuzzer validation. Done means the incorrect allocation case is rejected or the unsupported operands are prevented.

Written by the indexing model from the issue text.

Description

It's possible for vregs to be used or defined in branch instructions, but the fuzzer doesn't seem to check for these operands.

The following doesn't pass the fuzzer:

block0:
 0. branch(1). operands: [def v0 (fixed: p0)] // Allocation: [v0: p0]

block1:
 1. operands: [use v0 (fixed: p0)] // Allocation: [v0: p0]

And this does:

block0:
 0. operand: [def v0 (fixed: p0)] // Allocation: [v0: p0]
 1. branch(1). operands: [use v0 (fixed: p1)] // Allocation: [v0: p9]

block1:
 2. operands: [use v0 (fixed: p0)] // Allocation: [v0: p0]

Which is incorrect.

To reproduce this, run the tests in src/fastalloc/tests.rs at https://github.com/d-sonuga/regalloc2/tree/975dee0ceb56bbc6cbd21554a237babe1e388573.

To resolve this issue, one of the following could be done:

  • Disallow operands in branch instructions.
  • Update the fuzzer to check for these operands.
Dominant language
Rust
Stars
266
Forks
54
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bytecodealliance/regalloc2

All issues in bytecodealliance/regalloc2

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.