Skip to content

Fix VMDEBUG #13147

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

composerinteralia
Copy link
Contributor

I've found some of the VMDEBUG levels helpful in learning how things work. But prior to this commit there were some compile errors, as well as a failed assertion and an early exit. I'd guess that VMDEBUG is not commonly used, and these things didn't get updated as the surrounding code changed.

@@ -65,13 +65,6 @@ calc_pos(const rb_iseq_t *iseq, const VALUE *pc, int *lineno, int *node_id)
/* use pos-1 because PC points next instruction at the beginning of instruction */
pos--;
}
#if VMDEBUG && defined(HAVE_BUILTIN___BUILTIN_TRAP)
Copy link
Contributor Author

@composerinteralia composerinteralia Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We end up in this branch fairly frequently with pos == 0. I've removed it for now, otherwise this will terminate any program right away.

@@ -381,6 +381,8 @@ vm_stack_dump_each(const rb_execution_context_t *ec, const rb_control_frame_t *c
else {
rb_bug("unsupported frame type: %08lx", VM_FRAME_TYPE(cfp));
}
error:
Copy link
Contributor Author

@composerinteralia composerinteralia Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kprintf macro used above has a goto error. All of this is within a #if VMDEBUG > 2

@@ -429,7 +429,7 @@ vm_push_frame(rb_execution_context_t *ec,

ec->cfp = cfp;

if (VMDEBUG == 2) {
if (VMDEBUG == 2 && rb_current_execution_context(false) != NULL) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this I get:

../vm_core.h:1988: Assertion Failed: rb_current_execution_context:!expect_ec || ec != NULL

It happens during vm init, pushing a dummy frame before ruby_current_ec has been set (Init_BareVM -> th_init -> rb_ec_initialize_vm_stack -> vm_push_frame).

@composerinteralia composerinteralia changed the title Get VMDEBUG flags working Get VMDEBUG working Apr 22, 2025
@composerinteralia composerinteralia changed the title Get VMDEBUG working Fix VMDEBUG Apr 22, 2025

This comment has been minimized.

I've found some of the VMDEBUG levels helpful in learning how things
work. But prior to this commit there were some compile errors, as well
as a failed assertion and an early exit. I'd guess that VMDEBUG is not
commonly used, and these things didn't get updated as the surrounding
code changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants