Skip to content

ICE with bytecode larger than 2^16 bytes on EOF #16593

@sbauer00

Description

@sbauer00

Description

solc terminates with an internal compiler error on a fuzzed program when targeting EOF. The program compiles without errors (albeit with a large size) when targeting non-EOF bytecode.

Environment

Compiler version: 0.8.34+commit.80d5c536.Linux.g++ and 0.8.34+commit.80d5c536.Darwin.appleclang
Compilation pipeline (legacy, IR, EOF): EOF + IR
Target EVM version (as per compiler settings): osaka
Framework/IDE (e.g. Foundry, Hardhat, Remix): CLI
EVM execution environment / backend / blockchain client: NA
Operating system: Linux x86/64 and macOS arm64

Steps to Reproduce

contract.sol

The smallest instance is currently about 2200 line of code. To keep the issue readable see https://gist.github.com/sbauer00/8700fab400ec8db9b269d7659fc588f7 for the code. I will keep you updated if I can reproduce this with less code.

input.json

{
  "language": "Solidity",
  "sources": {
    "contract.sol": {
      "urls": ["contract.sol"]
    }
  },
  "settings": {
    "evmVersion": "osaka",
    "viaIR": true,
    "optimizer": {
      "enabled": true,
      "runs": 10,
      "details": {
        "yul": true,
        "yulDetails": {
          "optimizerSteps": "[OfFgUFMiVSSom]s[u]af[CtjMFEC]:LF"
        }
      }
    },
    "eofVersion": 1,
    "outputSelection": {
      "*": {
        "*": ["evm.bytecode", "evm.deployedBytecode"]
      }
    }
  }
}

Build

solc --standard-json < input.json

Output

Internal compiler error:
/solidity/libsolidity/interface/CompilerStack.cpp(1479): Throw in function void solidity::frontend::CompilerStack::assembleYul(const ContractDefinition &, std::shared_ptr<evmasm::Assembly>, std::shared_ptr<evmasm::Assembly>)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: Assembly exception for bytecode: Assertion failed
[solidity::util::tag_comment*] = Assembly exception for bytecode: Assertion failed
","message":"Internal compiler error:
/solidity/libsolidity/interface/CompilerStack.cpp(1479): Throw in function void solidity::frontend::CompilerStack::assembleYul(const ContractDefinition &, std::shared_ptr<evmasm::Assembly>, std::shared_ptr<evmasm::Assembly>)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: Assembly exception for bytecode: Assertion failed
[solidity::util::tag_comment*] = Assembly exception for bytecode: Assertion failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛low effortThere is not much implementation work to be done. The task is very easy or tiny.low impactChanges are not very noticeable or potential benefits are limited.nice to haveWe don’t see a good reason not to have it but won’t go out of our way to implement it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions