solc-js
solc-js copied to clipboard
ICE when running inside Azure App Function: `You shall not have another CompilerStack aside me`
Hey guys running into an error when running solc-js inside of Azure App Function. Everything compiles and works fine locally but not in the cloud. Tried both node v14 and v16
[
{
"component": "general",
"formattedMessage": "Internal exception in StandardCompiler::compile: /solidity/libsolidity/interface/CompilerStack.cpp(104): Throw in function solidity::frontend::CompilerStack::CompilerStack(ReadCallback::Callback)\nDynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>\nstd::exception::what: You shall not have another CompilerStack aside me.\n[solidity::util::tag_comment*] = You shall not have another CompilerStack aside me.\n",
"message": "Internal exception in StandardCompiler::compile: /solidity/libsolidity/interface/CompilerStack.cpp(104): Throw in function solidity::frontend::CompilerStack::CompilerStack(ReadCallback::Callback)\nDynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>\nstd::exception::what: You shall not have another CompilerStack aside me.\n[solidity::util::tag_comment*] = You shall not have another CompilerStack aside me.\n",
"severity": "error",
"type": "InternalCompilerError"
}
]
Can you give more information about how you exactly started the application and what lead to that error?
@chriseth Here is the relevant azure function code
const input = {
language: 'Solidity',
sources: {
[templateName]: {
content: eval(templateContents)
}
},
settings: {
outputSelection: { // return everything
'*': {
'*': ['*']
}
}
}
}
context.log('about to launch solc compiler')
const output = JSON.parse(
solc.compile(JSON.stringify(input), { import: findImports })
);
if(output.errors) {
return {
statusCode: 400,
body: JSON.stringify(output.errors)
}
}
(I know I know eval is bad) The function itself is triggered by an HTTP POST call to https://compile-smart-contract.azurewebsites.net/api/compile-smart-contract with a payload that looks like this
{
"blockchain": 1,
"network": "4",
"hasWhitelist": true,
"hasDelayedReveal": true,
"hasOpenSeaRoyalties": true,
"baseURL": "ipfs://",
"name": "Bored Apes Yacht Club",
"symbol": "BAYC",
"collectionSize": 444,
"mintPrice": 0.05,
"maxTokensPerTransaction": 20,
"whitelistPrice": 0.04,
"delayedRevealURL": "ipfs://",
"email": "[email protected]",
"voucherSigner": "abcdefjhijklmnop"
}
Tried both node v14.14 and v16.4.1
Does it happen only on Azure or can you also reproduce it locally? I tried it on my machine and I did not get that error but it might just be something in the parts that are not included in your example. E.g. your Solidity source or import callback.
From the info we have so far I can only say that CompilerStack
class in the C++ code gets created twice and it's not supposed to so our sanity check fails. Unfortunately it's not enough to tell why this happens.
We'll need a more concrete repro to be able to diagnose this. Could you create a small, self-contained JS snippet that reproduces this? I.e. without any missing parts but for our purposes it's enough to replace them with the simplest equivalent that still makes it crash.
Closing as a duplicate of #675. This issue was first but the other one has a repro.
Looks like the problem occurs when an exception interrupts the import callback and you continue to use the compiler after that. This will need a fix in the compiler. For now a crude workaround would probably be to reload the compiler.