Skip to content

Enabling yul optimizer and viaIR causes stack too deep error using Solidity 0.8.19 #544

@r0qs

Description

@r0qs

Description

Hi, we recently find an issue when compiling safe-contracts in our test suite using the latest version of the Solidity compiler with the yul optimizer enabled. You can read more details and discussions about the issue here: argotorg/solidity#14082

In summary, it throws stack too deep error (see below) when using the following compiler settings: {"viaIR":true,"optimizer":{"enabled":true, "details": {"yul": true}}}

The problem was introduced by this commit: b9fdbde

Environment

  • Compiler version: 0.8.19
  • Compiler settings: evmVersion: 'paris', viaIR: true, optimizer: {enabled: true, details: {yul: true}}}

Steps to Reproduce

Set the .env to:

SOLIDITY_VERSION="0.8.19"
SOLIDITY_SETTINGS='{"viaIR":true,"optimizer":{"enabled":true, "details": {"yul": true}}}'

And run: yarn build. This will produce the following error:

YulException: Cannot swap Variable var_operation with Variable _1: too deep in the stack by 4 slots in [ var_operation RET var_operation var_data_length var_signatures_mpos var_signatures_mpos var_to var_refundReceiver var_gasToken var_gasPrice var_baseGas var_safeTxGas var_value var_data_174_offset var_refundReceiver var_to var_data_length var_value var_gasToken var_gasPrice var_baseGas var_safeTxGas _1 ]
No memoryguard was present. Consider using memory-safe assembly only and annotating it via 'assembly ("memory-safe") { ... }'.


Error HH600: Compilation failed

Possible solution

Add the "memory-safe" annotation to assembly code blocks when needed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions