Skip to content

s390x runtime: use unsigned comparisons for "less than" comparisons between pointers#12258

Merged
xavierleroy merged 1 commit intoocaml:trunkfrom
xavierleroy:Z-clg
May 24, 2023
Merged

s390x runtime: use unsigned comparisons for "less than" comparisons between pointers#12258
xavierleroy merged 1 commit intoocaml:trunkfrom
xavierleroy:Z-clg

Conversation

@xavierleroy
Copy link
Copy Markdown
Contributor

When comparing the young pointer with the young limit, or the stack pointer with some bound, always use unsigned comparisons (clg instruction), not signed comparisons (cg). The latter causes surprises like #11712 (comment)

@xavierleroy
Copy link
Copy Markdown
Contributor Author

With the unsigned comparisons, the strange ocamlopt.opt crash in testsuite/tests/callback/callback_effects_gc.ml goes away.

Copy link
Copy Markdown
Contributor

@lthls lthls left a comment

Choose a reason for hiding this comment

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

Looks good to me.

/* Copy arguments from OCaml to C stack */
LBL(105):
lay %r8, -8(%r8)
cgr %r8, %r9
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just to be sure: this one is unrelated to the testsuite failure, but fixes potential errors if the OCaml stack pointer is close to 0x8000000000000000. Correct ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correct! All comparisons between pointers should be unsigned, because signed compares give wrong results around the "equator" (2^63 or 2^31).

@xavierleroy xavierleroy merged commit 30a0f93 into ocaml:trunk May 24, 2023
@xavierleroy xavierleroy deleted the Z-clg branch May 24, 2023 06:53
Octachron pushed a commit that referenced this pull request May 25, 2023
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.

2 participants