Skip to content

YJIT: Side-exit on String#dup when it's not leaf #13921

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

Merged
merged 2 commits into from
Jul 16, 2025

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Jul 16, 2025

This fixes ccbbe06.

rb_obj_dup is not leaf, so it gives a wrong backtrace if you skip pushing a frame when the string has ivars and falls back to rb_obj_dup. This PR changes it to side-exit, reversing the simplification we made in #13606.

@k0kubun k0kubun marked this pull request as ready for review July 16, 2025 22:01
@matzbot matzbot requested a review from a team July 16, 2025 22:01
@k0kubun k0kubun requested a review from byroot July 16, 2025 22:02
@k0kubun k0kubun linked an issue Jul 16, 2025 that may be closed by this pull request
Copy link
Contributor

@tekknolagi tekknolagi left a comment

Choose a reason for hiding this comment

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

lgtm with one q

shape.h Outdated
@@ -48,7 +48,8 @@ enum shape_id_fl_type {

// This masks allows to check if a shape_id contains any ivar.
// It rely on ROOT_SHAPE_WITH_OBJ_ID==1.
#define SHAPE_ID_HAS_IVAR_MASK (SHAPE_ID_FL_TOO_COMPLEX | (SHAPE_ID_OFFSET_MASK - 1))
#define SHAPE_ID_HAS_IVAR_MASK 0x807fffe
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need this constant inline?

Copy link
Member Author

Choose a reason for hiding this comment

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

For bindgen.

Copy link
Member

@XrXr XrXr Jul 16, 2025

Choose a reason for hiding this comment

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

This is a bindgen limitation where it can't tell whether a macro is a constant. An alternative is to put the expression in an anonymous enum, which bindgen can figure out since it's a language level thing to force a value to be compile time known and not allocate storage for it.
Could you try that? If it doesn't work for some C code or whatever, as is isn't too horrible.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure thing

Copy link
Contributor

Choose a reason for hiding this comment

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

A secret third thing is to make a uint32_t abc = SHAPE_ID_HAS_IVAR_MASK in jit.c and then bindgen that

Copy link
Contributor

@tekknolagi tekknolagi Jul 16, 2025

Choose a reason for hiding this comment

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

(If we care about signedness, which it looks like we do, we can't really rely on enum signedness. and I think enum width, too)

Copy link
Member Author

@k0kubun k0kubun Jul 16, 2025

Choose a reason for hiding this comment

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

like this? fae2039

Copy link
Member

Choose a reason for hiding this comment

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

No need to worry about signedness because the operands in the expression come from enum themselves 😁 Go integer promotion.

This comment has been minimized.

@k0kubun k0kubun enabled auto-merge (squash) July 16, 2025 22:33
@k0kubun k0kubun merged commit 571a8d2 into ruby:master Jul 16, 2025
83 checks passed
@k0kubun k0kubun deleted the yjit-str-canary branch July 17, 2025 09:38
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

Successfully merging this pull request may close these issues.

YJIT: Stack canary gets killed in a btest
4 participants