mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Handle bad instructions (BadInstruction exception) [#81563132]
This commit is contained in:
parent
ac38bf9ac1
commit
6da6f3dc52
4 changed files with 15 additions and 5 deletions
1
evmcc/test/except/badinst1.evm
Normal file
1
evmcc/test/except/badinst1.evm
Normal file
|
|
@ -0,0 +1 @@
|
|||
4a
|
||||
|
|
@ -816,6 +816,11 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
break;
|
||||
}
|
||||
|
||||
default: // Invalid instruction - runtime exception
|
||||
{
|
||||
_runtimeManager.raiseException(ReturnCode::BadInstruction);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ enum class ReturnCode
|
|||
|
||||
BadJumpDestination = 101,
|
||||
OutOfGas = 102,
|
||||
StackTooSmall = 103
|
||||
StackTooSmall = 103,
|
||||
BadInstruction = 104,
|
||||
};
|
||||
|
||||
struct Constant
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "ExecutionEngine.h"
|
||||
#include "Compiler.h"
|
||||
#include "Type.h"
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
|
@ -20,14 +21,16 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const&, uint64_t)
|
|||
ExecutionEngine engine;
|
||||
auto exitCode = engine.run(std::move(module), m_gas, &_ext);
|
||||
|
||||
switch (exitCode)
|
||||
switch (static_cast<ReturnCode>(exitCode))
|
||||
{
|
||||
case 101:
|
||||
case ReturnCode::BadJumpDestination:
|
||||
BOOST_THROW_EXCEPTION(BadJumpDestination());
|
||||
case 102:
|
||||
case ReturnCode::OutOfGas:
|
||||
BOOST_THROW_EXCEPTION(OutOfGas());
|
||||
case 103:
|
||||
case ReturnCode::StackTooSmall:
|
||||
BOOST_THROW_EXCEPTION(StackTooSmall(1,0));
|
||||
case ReturnCode::BadInstruction:
|
||||
BOOST_THROW_EXCEPTION(BadInstruction());
|
||||
}
|
||||
|
||||
m_output = std::move(engine.returnData);
|
||||
|
|
|
|||
Loading…
Reference in a new issue