ICE when loading the same file multiple times via import callback
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## 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`:
```solidity
{
"language": "Solidity",
"sources": {
"A": {"urls": ["/tmp/test.sol"]},
"B": {"urls": ["/tmp/test.sol"]}
}
}
```
`/tmp/test.sol`
```solidity
// SPDX-License-Identifier: MIT
pragma solidity *;
contract C {}
```
```bash
solc --standard-json input.json --pretty-json --json-indent 4
```
Output:
```json
{
"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\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\nstd::exception::what: Solidity assertion failed\n[solidity::util::tag_comment*] = Solidity assertion failed\n",
"severity": "error",
"type": "IOError"
}
],
"sources": {
"A": {
"id": 0
}
}
}
```
Contributor guide
Research direction
Reproduce the issue with input.json, /tmp/test.sol, and the shown solc command, then inspect solidity/libsolidity/interface/FileReader.cpp around line 164 and the import callback path. Done means loading the same URL for multiple sources no longer produces an InternalCompilerError and reports the expected compilation result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100