Skip to content

solc hangs when compiling with addmod #16109

@rhaoio

Description

@rhaoio

Description

solc will hang when compiling a library using addmod in a function call. I tested this on Remix, Ubuntu 20.04, Ubuntu 22.04 and it only hangs in:

Ubuntu 22.04 - installed via apt-get. The resulting binary appears to be dynamically linked. Interestingly, Ubuntu 20.04 installs a static binary and it will compile.

Environment

  • Compiler version:0.8.30+commit.73712a01.Linux.g++
  • Compilation pipeline (legacy, IR, EOF): legacy (simple just solc --input-file test.sol
  • Target EVM version (as per compiler settings): prague
  • Framework/IDE (e.g. Foundry, Hardhat, Remix): ethers-rs / cli
  • EVM execution environment / backend / blockchain client:
  • Operating system: Ubuntu 22.04

Steps to Reproduce

Install 0.8.30+commit.73712a01.Linux.g++ via the following steps on UBUNTU 22.04
(from solidity website)

sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc

Compile the below library

touch test.sol
solc --input-file test.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

library TestAddmodVariants {
    uint256 constant q_mod = 21888242871839275222246405745257275088548364400416034343698204186575808495617;

    function simple_add(uint256 a, uint256 b) internal pure returns (uint256) {
        return addmod(a, b, q_mod);
    }
}

This should hang on Ubuntu 22.04, using the dynamically linked compiler.
Ldd info for 22.04

ldd $(which solc)
        linux-vdso.so.1 (0x00007fff86fc0000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x0000736f6ba00000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x0000736f6c9dd000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000736f6b600000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x0000736f6bd19000)
        /lib64/ld-linux-x86-64.so.2 (0x0000736f6ca0a000)

Would appreciate if someone could reproduce this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions