paritytech / paritytech/revive
Wasm build does not output panics to the JSON `errors` array
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 102
- Forks
- 26
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 6
Description
Description
In --standard-json mode, when a panic occurs in resolc the native builds are consistent with solc and terminate in a success state with errors reported in the JSON output via stdout.
The Wasm build behaves similarly for errors, but not when panics occur:
| Build | Exit Code | stdout | stderr |
|---|---|---|---|
| Native | 0 | JSON with populated errors array |
empty |
| Wasm | 101 | empty | panic message |
Tested with:
- resolc 1.0.0
- resolc 0.6.0
Minimal Reproduction
1. Create a file that triggers a panic
This example uses the _ function naming collision bug to trigger a panic:
cat > trigger-ice.yul << 'EOF'
object "Test" {
code {
{
let size := datasize("Test_deployed")
codecopy(0, dataoffset("Test_deployed"), size)
return(0, size)
}
}
object "Test_deployed" {
code {
{
_()
log0(0, 32)
}
function _() {
mstore(0, 0xdeadbeef)
log0(0, 32)
}
}
}
}
EOF
2. Download soljson.js
This downloads it to resolc-wasm/soljson.js:
curl -sSLo resolc-wasm/soljson.js https://github.com/ethereum/solidity/releases/download/v0.8.33/soljson.js
3. Compile the file with Wasm resolc
This assumes you have resolc.js, resolc.wasm, and soljson.js in ./resolc-wasm/:
(resolc v1.0.0 used here)
node -e "
const fs = require('fs');
const createResolc = require('./resolc-wasm/resolc.js');
const soljson = require('./resolc-wasm/soljson.js');
const input = {
language: 'Yul',
sources: {
'trigger-ice.yul': {
content: fs.readFileSync('trigger-ice.yul', 'utf8')
}
},
settings: {
optimizer: {
enabled: false
},
outputSelection: {
'*': {
'*': ['evm.bytecode']
}
}
}
};
const compiler = createResolc();
compiler.soljson = soljson;
compiler.writeToStdin(JSON.stringify(input));
const exitCode = compiler.callMain(['--standard-json']);
console.log('Exit code:', exitCode);
console.log('stdout:');
console.log(compiler.readFromStdout());
console.log('stderr:');
console.log(compiler.readFromStderr());
"
Expected Output
- Exit code: 0
- stdout: JSON with the error in the
errorsarray - stderr: empty
Actual Output
Exit code: 101
stdout:
stderr:
thread 'main' (1) panicked at crates/resolc/src/process/worker_process.rs:91:37:
Worker error:
thread 'main' (1) panicked at crates/llvm-context/src/polkavm/context/mod.rs:459:9:
ICE: function '_' declared subsequentally
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the panic with the provided Wasm Node command, then inspect crates/resolc/src/process/worker_process.rs and crates/llvm-context/src/polkavm/context/mod.rs around the reported panic locations. Trace how --standard-json handles worker errors in the Wasm build. Done means exit code 0, JSON with the error in the stdout errors array, and empty stderr.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100