argotorg / argotorg/solidity

When compiling with the `via-ir` option, calldata out-of-bounds causes the transaction to revert

Open
#14,897 1 comment 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Environment

- Compiler version: solc 0.8.24
- Framework/IDE (e.g. Truffle or Remix): foundry

## Steps to Reproduce

Hello! I compiled the following contract using the `via-ir` option. A revert occurred during transaction execution.

```solidity
contract A {
function f(uint[2] calldata x) public pure returns(uint[2] memory r) {
assembly {{ x := 0x24 }}
r = x;
}
}
```

If I change the return type of `r` to uint, an out-of-bounds situation similarly occurs. However, after compiling with `via-ir`, the transaction successfully executes and returns `0x0`.

```solidity
contract B {
function f(uint[2] calldata x) public pure returns(uint r) {
assembly {{ x := 0x24 }}
r = x[1];
}
}
```

Notably, if I omit the `via-ir` option, both return as expected. Is this a bug? I'm uncertain if this revert is caused by an out-of-bounds check.

Contributor guide

Open the contributing guide

Research direction

Start by compiling contracts A and B with solc 0.8.24 using and omitting the via-ir option, then reproduce their transaction behavior. Compare the generated behavior around calldata out-of-bounds handling and determine whether the differing revert is expected; done means the behavior is explained and, if incorrect, covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
blockchain, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.