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

Watch expression interpreter non 64bit signed integer right shift does not carry sign bit #286

Open
GloriousNull opened this issue Jul 6, 2024 · 1 comment
Labels
Bug A report of unintended or broken behavior. Debugger Pertains to the debugger.

Comments

@GloriousNull
Copy link

Couldn't find similar issue so here it goes. version 0.9.11 but was present in 0.9.10 too.

BUG: Because watch tab expression interpreter evaluates expressions in 64 bit values for signed integers right shift does not carry sign bit for 32bit, 16bit, 8bit signed integers which is expected behaviour on x86. Maybe it's not that important but it caused me some confusion :D Attaching repro.

I could do PR with fix but quick fix caused weird watch display behaviour so I pass that to you :)
Also you are missing EVAL_ExprKind_BitNot in eval_g_unary_prefix_op_table in eval_parser.c so "bit not" operation is not working in watch tab.

And watch incorrectly displays s32 value casted to u32 which is mentioned in repro.
watch_interpreter_signed_integer_right_shift_bug.zip

@GloriousNull
Copy link
Author

GloriousNull commented Jul 6, 2024

Bug is a bit more subtle than I assumed. Interpreter correctly carries sign for shifts because RDI_EvalOp_TruncSigned is being emitted by the eval_compiler but this is not the case for values that are positive and become negative in run-time due to shift left operation. So debugger treats such values as positive because it never sign extended them to S64 for interpreter

@ryanfleury ryanfleury added the Bug A report of unintended or broken behavior. label Jul 15, 2024
@ryanfleury ryanfleury added the Debugger Pertains to the debugger. label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A report of unintended or broken behavior. Debugger Pertains to the debugger.
Projects
None yet
Development

No branches or pull requests

2 participants