7

Solidity generates EVM bytecode that leads to an invalid jump destination when:

  • throw is used
  • ... ?
  • ... ?

Can the above list be completed, with examples?

To explain the first item, throw in Solidity source code, gets compiled to EVM bytecode that leads to an invalid jump destination. (Of course it assumes that the throw is not in dead code that might be optimized away.) What are all the other scenarios that belong in the list?

8

Jumps to invalid jump destinations are generated only for (explicit or implicit) exceptions. An explicit exception is when you use the keyword throw. Implicit exceptions happen for runtime errors:

  • array access out of bounds
  • failed sub-call (due to any reason reported by the EVM including invalid jump dest in the sub-call)
  • ether sent to a library fallback function
  • I'd add: sending ether to a function not defined as payable – dangerous.beans Dec 8 '16 at 1:59
5

Array Out Of Bounds

contract InvalidJump {
    uint[5] data;

    function invalidJump1() {
       uint i = 6000;
       data[i] = 1;
    }
}

And the message is from debug.traceTransaction(...) is:

error: "invalid jump destination (PUSH1) 2"


(Somewhat Related) Stack Limit Reached 1024

Not what was asked in the question, but interesting anyway.

contract InvalidJump2 {
    function invalidJump2(uint number) {
        invalidJump2(number - 1);
    }
}

Calling with the following transaction:

invalidJump.invalidJump2(1, eth.accounts[0], {
  from:web3.eth.accounts[0], 
  data: invalidJumpCompiled.InvalidJump.code,
  gas: 1000000
});

And the error message:

I0607 18:04:49.978794 core/state_transition.go:258] VM call err: stack limit reached 1024 (1024)

Plus the debug.traceTransaction(...) sends the geth console screen crazy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.