Skip to content

ICE when loading the same file multiple times via import callback #15458

Open
@cameel

Description

@cameel

Description

When the same path is specified under urls of multiple contracts in Standard JSON input, we get an ICE in the import callback.

Environment

  • Compiler version: 0.8.27

Steps to Reproduce

input.json:

{
    "language": "Solidity",
    "sources": {
        "A": {"urls": ["/tmp/test.sol"]},
        "B": {"urls": ["/tmp/test.sol"]}
    }
}

/tmp/test.sol

// SPDX-License-Identifier: MIT
pragma solidity *;

contract C {}
solc --standard-json input.json --pretty-json --json-indent 4

Output:

{
    "errors": [
        {
            "component": "general",
            "formattedMessage": "Cannot import url (\"/tmp/test.sol\"): Exception in read callback: /solidity/libsolidity/interface/FileReader.cpp(164): Throw in function solidity::frontend::ReadCallback::Result solidity::frontend::FileReader::readFile(const std::string&, const std::string&)\nDynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>\nstd::exception::what: Solidity assertion failed\n[solidity::util::tag_comment*] = Solidity assertion failed\n",
            "message": "Cannot import url (\"/tmp/test.sol\"): Exception in read callback: /solidity/libsolidity/interface/FileReader.cpp(164): Throw in function solidity::frontend::ReadCallback::Result solidity::frontend::FileReader::readFile(const std::string&, const std::string&)\nDynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>\nstd::exception::what: Solidity assertion failed\n[solidity::util::tag_comment*] = Solidity assertion failed\n",
            "severity": "error",
            "type": "IOError"
        }
    ],
    "sources": {
        "A": {
            "id": 0
        }
    }
}

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.must have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.should compile without errorError is reported even though it shouldn't. Source is fine.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions