Skip to content
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

Questionable behavior of the normally unused instruction OP_DEBUG #5686

Open
dearblue opened this issue Apr 9, 2022 · 0 comments
Open

Questionable behavior of the normally unused instruction OP_DEBUG #5686

dearblue opened this issue Apr 9, 2022 · 0 comments

Comments

@dearblue
Copy link
Contributor

dearblue commented Apr 9, 2022

I just followed the code by eye, so if I'm wrong or that's the intended behavior, please ignore it.

  1. two consecutive FETCH_XXX() from iseq may

    While OP_DEBUG is defined as operand type BBB in include/mruby/ops.h, it is defined as operand type Z in src/vm.c followed by FETCH_BBB().
    I assume that OP_DEBUG always intends to FETCH_BBB(), but if the operand is extended with instruction OP_EXT3, for example, FETCH_SSB() is performed followed by FETCH_BBB().

    If this is not the intention, it is better to change OP_DEBUG in src/vm.c to BBB or OP_DEBUG in include/mruby/ops.h to Z.

  2. inconsistency when the configuration macro MRB_USE_DEBUG_HOOK is defined

    In normal instructions, mrb->debug_op_hook() is called before decoding the operand.
    For OP_DEBUG, mrb->debug_op_hook() is called again after FETCH_BBB(). In addition, NULL check of mrb->debug_op_hook is not performed at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant