-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Distinguish between INVALID opcode and unknown opcodes in aleth-interpreter #5666
Conversation
and EVMC_UNDEFINED_INSTRUCTION for not defined opcodes
| DEFAULT | ||
| { | ||
| throwBadInstruction(); | ||
| if (m_OP == Instruction::INVALID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouln't it be just
CASE(INVALID)
throwInvalidInstruction();
DEFAULT
throwUndefinedInstruction();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this doesn't work on gcc/clang, because the jump table is populated with INVALID opcode for all unknown ones
aleth/libaleth-interpreter/VMConfig.h
Line 154 in 089e7dd
| static const void* const jumpTable[256] = { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we change that by having &&UNDEFINED everywhere and &&INVALID in
aleth/libaleth-interpreter/VMConfig.h
Line 409 in 089e7dd
| &&INVALID, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no such thing as UNDEFINED, and this enum is 8 bit-wide
Line 28 in 2b11ce5
| enum class Instruction : uint8_t |
So we can't really add UNDEFINED unless we change the width
Codecov Report
@@ Coverage Diff @@
## master #5666 +/- ##
=========================================
Coverage ? 63.01%
=========================================
Files ? 350
Lines ? 29922
Branches ? 3353
=========================================
Hits ? 18856
Misses ? 9851
Partials ? 1215 |
a8b4c0a to
e042a52
Compare
This fixes the failure of
evm.invalidtest, which expectsEVMC_INVALID_INSTRUCTIONto be returned forINVALID(0xfe) opcode andEVMC_UNKNOWN_INSTRUCTIONfor all not defined opcodes.