Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jan 19, 2024

This is the fix for #12917. It turns out caml_callback2_asm uses a callee-saved register without saving it, and we have been incredibly lucky this was not noticed until this week.

Rather than save then restore that register, I'm using another incoming argument temporary register as the temporary in this case. This makes the diff almost trivial and easy to check. I also seized the opportunity to add a warning notice about r12 usage to our future selves.

It would be nice if this could also get backported to 5.2.

@gasche
Copy link
Member

gasche commented Jan 19, 2024

cc maybe @xavierleroy , who knows about s390x

@damiendoligez damiendoligez self-requested a review February 7, 2024 14:36
Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

I believe that this PR is correct, and propose to merge in trunk and 5.2.

We have been very lucky not to notice any ill-effect from this, but gcc 14
apparently uses r12 more aggressively and this bug causes
tests/callback/callback_effects_gc.ml to reliably cause a segmentation fault
without this fix.
@gasche gasche merged commit de22ce0 into ocaml:trunk Feb 7, 2024
gasche added a commit that referenced this pull request Feb 7, 2024
s390x: fix register corruption in runtime
(cherry picked from commit de22ce0)
@ghost ghost deleted the s390x_register_corruption branch February 9, 2024 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants