New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer overflow in codegen #3426

Closed
clayton-shopify opened this Issue Feb 2, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@clayton-shopify
Contributor

clayton-shopify commented Feb 2, 2017

An integer overflow in the codegen (leading to a segfault) can be demonstrated as follows:

ruby -e 'puts "begin" ; puts "rescue" ; 16380.times { puts "a" } ; puts "end"' | bin/mruby -v

The generated code begins as follows:

irep 0x7fb97e500020 nregs=3 nlocals=1 pools=0 syms=3 reps=0
file: -
    2 000 OP_ONERR	003
    2 001 OP_LOADNIL	R1
    2 002 OP_JMP	-32765
    2 003 OP_RESCUE	R1

Clearly the generated OP_JMP is invalid.

I see that jumps are 16 bit, so I guess the codegen should either detect the problem and exit, or cope with it some other way.

This issue was reported by https://hackerone.com/ssarong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment