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

Truncated JSON output from emscripten binary with viaIR: true and both ir and * selected as outputs #14362

Open
cameel opened this issue Jun 26, 2023 · 0 comments
Labels
bug 🐛 medium effort Default level of effort medium impact Default level of impact must have Something we consider an essential part of Solidity 1.0. should compile without error Error is reported even though it shouldn't. Source is fine. solcjs

Comments

@cameel
Copy link
Member

cameel commented Jun 26, 2023

The snippet from #14361 has one more weird effect that looks unrelated to that issue. When I select * output together with ir, enable viaIR and pass it to the emscripten binary, the produced JSON is truncated.

It only happens when these outputs are both selected at the same time. Changing the snippet to something simple like contract {} resolves the problem as well so it's something in the code that triggers it. Unlike in #14361, this happens both with and without optimizer.

It's possible that solc-js crashes in the process, but there's nothing in the output that would indicate that (no Killed or core dumped on the console). The fact that it always cuts off at the same point would also indicate that it's the JSON generation that suddenly decides to stop for whatever reason, but then successfully outputs that unfinished content.

Environment

Tested with solc-js 0.8.20 with the binary included in the release.

Repro

input.json

{
    "language": "Solidity",
    "sources": {
        "A": {"content": "
            contract C {
                function f2() public {
                    bytes1[2] memory k;
                    k[0] = bytes1(0);
                }
            }"
        }
    },
    "settings": {
        "viaIR": true,
        "outputSelection": {
            "*": {"*": ["ir", "*"]}
        }
    }
}

Script

npm install solc
emscripten_output=$(cat input.json | npx --no -- solcjs --standard-json)
echo "$emscripten_output"
echo "$emscripten_output" | jq

Output

The output from jq is:

parse error: Unfinished string at EOF at line 2, column 0

which means that the produced JSON is malformed. And indeed, this is how it ends:

}\n\n            function write_to_memory_t_bytes1(memPtr, value) {\n                mstore(memPtr, cleanup_t_bytes1(value))\

This is the content of the ir field, which is not terminated. The Standard JSON output just ends abruptly in the middle of it.

@cameel cameel added bug 🐛 should compile without error Error is reported even though it shouldn't. Source is fine. solcjs medium effort Default level of effort medium impact Default level of impact must have Something we consider an essential part of Solidity 1.0. labels Jun 26, 2023
@cameel cameel moved this to To do in Solidity Focus Board Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 medium effort Default level of effort medium impact Default level of impact must have Something we consider an essential part of Solidity 1.0. should compile without error Error is reported even though it shouldn't. Source is fine. solcjs
Projects
Development

No branches or pull requests

1 participant