From 3246d0f9a907774674e7e7d4ebd6314772cf7adc Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 9 Nov 2020 18:11:44 +0000 Subject: [PATCH] [solc] Handle exceptions in AssemblyStack.translate() gracefully --- solc/CommandLineInterface.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 1d8e24b7e..42fe58a3b 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -1883,8 +1883,29 @@ bool CommandLineInterface::assemble( if (_language != yul::AssemblyStack::Language::Ewasm && _targetMachine == yul::AssemblyStack::Machine::Ewasm) { - stack.translate(yul::AssemblyStack::Language::Ewasm); - stack.optimize(); + try + { + stack.translate(yul::AssemblyStack::Language::Ewasm); + stack.optimize(); + } + catch (Exception const& _exception) + { + serr() << "Exception in assembler: " << boost::diagnostic_information(_exception) << endl; + return false; + } + catch (std::exception const& _e) + { + serr() << + "Unknown exception during compilation" << + (_e.what() ? ": " + string(_e.what()) : ".") << + endl; + return false; + } + catch (...) + { + serr() << "Unknown exception in assembler." << endl; + return false; + } sout() << endl << "==========================" << endl; sout() << endl << "Translated source:" << endl;