Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTChecker: Internal compiler error in BMC analysis of loop condition #15847

Open
lum7na opened this issue Feb 11, 2025 · 1 comment
Open

SMTChecker: Internal compiler error in BMC analysis of loop condition #15847

lum7na opened this issue Feb 11, 2025 · 1 comment
Assignees

Comments

@lum7na
Copy link

lum7na commented Feb 11, 2025

Description

Hi! Solc throws an internal compiler error within UniqueErrorReporter.h when enabling model-checker. I attempted to minimize the reproduction code, but it seems that removing any single expression prevents triggering this exception.

Compile: solc-latest a.sol --model-checker-engine all

contract Test {
  function test(string memory str) private returns(string memory) {
    bytes memory s = bytes(str);
    if (s.length > 0) {
      bool b = true;
      for (uint i = 0;i < s.length; i++) {
        if (s[i] != hex"20") {
          b = false;
          break;
        }
      }
      if (b) {
        return hex"";
      } else {
        bytes memory t = new bytes(s.length);
        uint j = 0;
        for (uint i = 0;i < s.length; i++) {
          if (s[i] != hex"20") {
            j++;
          }
        }
        bytes memory r = new bytes(j);
        for (uint k = 0; 0 < ((((r[1] == hex"7e" ? j : 0) != k ? 0 : j) == 2) ? 45 : j); k++) {
          r[k] = t[k];
        }
        return string(r);
      }
    }
    return str;
  }
}

Output:

Internal compiler error:
/solidity/liblangutil/UniqueErrorReporter.h(87): Throw in function bool solidity::langutil::UniqueErrorReporter::seen(solidity::langutil::ErrorId, const solidity::langutil::SourceLocation&, const std::string&) const
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: Solidity assertion failed
[solidity::util::tag_comment*] = Solidity assertion failed

Solc version: Version: 0.8.29-develop.2025.2.11+commit.c3152941.Linux.g++

@blishko blishko added the smt label Feb 12, 2025
@blishko blishko changed the title solc throws an internal compiler error within UniqueErrorReporter.h when enabling model-checker SMTChecker: Internal compiler error in BMC analysis of loop Feb 12, 2025
@blishko
Copy link
Contributor

blishko commented Feb 12, 2025

Here is the simplified example:

contract Test {
    function loop() public {
        for (uint k = 0; (k == 0 ? true : false); k++) {
        }
    }
}

The error is triggered in the BMC analysis of the loop condition (option --model-checker-engine bmc).

@blishko blishko changed the title SMTChecker: Internal compiler error in BMC analysis of loop SMTChecker: Internal compiler error in BMC analysis of loop condition Feb 12, 2025
@blishko blishko self-assigned this Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To Do
Development

No branches or pull requests

2 participants