Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Bytecode verifier is failing with try-catch statements #45

Open
ShadelessFox opened this issue Apr 1, 2021 · 0 comments
Open

Bytecode verifier is failing with try-catch statements #45

ShadelessFox opened this issue Apr 1, 2021 · 0 comments
Assignees
Labels
bug Something isn't working compiler Things related to the compiler

Comments

@ShadelessFox
Copy link
Owner

A bytecode verification feature was added in aa6aab1, but the code we're emitting for try-catch statements (#22, a9e3cbe) is not valid. Consider following code snippet:

try {
    return 1;
} finally {
    return 2;
}

It will generate following bytecode:

00000000 01 00 00 PUSH         2
00000003 19       RETURN       
00000004 01 00 01 PUSH         1
00000007 19       RETURN       
00000008 01 00 00 PUSH         2
0000000b 19       RETURN       
0000000c 01 00 00 PUSH         2
0000000f 19       RETURN       
00000010 07 00    GET_LOCAL    0
00000012 01 00 02 PUSH         none
00000015 1d       CMP_EQ       
00000016 1b 00 03 JUMP_IF_TRUE 3 (#L01)
00000019 07 00    GET_LOCAL    0
0000001b 2a       THROW        

Notice how weird it is and how many times the body of finally is repeated. The verifier itself is complaining about jump at 16 that is pointing literally nowhere (beyond the chunk itself), this should not happen.

@ShadelessFox ShadelessFox added bug Something isn't working compiler Things related to the compiler labels Apr 1, 2021
@ShadelessFox ShadelessFox self-assigned this Apr 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working compiler Things related to the compiler
Projects
None yet
Development

No branches or pull requests

1 participant