Skip to content

PR#7417: ensure stack stays 16 bytes aligned#930

Merged
gasche merged 2 commits intoocaml:trunkfrom
christoph-cullmann:trunk
Nov 27, 2016
Merged

PR#7417: ensure stack stays 16 bytes aligned#930
gasche merged 2 commits intoocaml:trunkfrom
christoph-cullmann:trunk

Conversation

@christoph-cullmann
Copy link
Contributor

See PR#7417

https://caml.inria.fr/mantis/view.php?id=7417

The WITH_FRAME_POINTERS leads to non-16 byte aligned stack addresses.

Try to fix that by manually align like it was done in other locations.

Unit tests seem to work better with that.

@christoph-cullmann
Copy link
Contributor Author

Added Changes entry.

@gasche
Copy link
Member

gasche commented Nov 26, 2016

It would be nice to have a review by someone familiar with assembly (I'm not competent here) and the general backend implementation/style; @bschommer, can you vouch for the patch correctness? Otherwise maybe @alainfrisch, @xavierleroy?

@nojb
Copy link
Contributor

nojb commented Nov 26, 2016

I am wondering if the same change is necessary in the other alloc* functions (eg the comment at https://github.com/ocaml/ocaml/blob/trunk/asmrun/amd64.S#L387).

@nojb
Copy link
Contributor

nojb commented Nov 26, 2016

To expand on my previous comment, it seems that all the functions alloc* are invoked via call so their stack is 8-aligned on entry (due to call pushing the return address). Therefore it should be made 16-aligned before invoking caml_call_gc.

(On closer reading, the code seems OK as it stands - the macros ENTER_FUNCTION and LEAVE_FUNCTION take care to 16-align the stack on the functions alloc1, alloc2 and alloc3).

@bschommer
Copy link
Contributor

I can confirm what @christoph-cullmann said. We now have the patch applied for about a week and have not encountered any problems on any of our internal-tests so far.

@christoph-cullmann
Copy link
Contributor Author

Yes, at all other places I think the stack is properly aligned before we issue the call instruction (and if I don't misread the ABI docs, it must be 16 byte aligned before the call instruction, not counting the effect of the call itself)

@gasche gasche merged commit 3ad607f into ocaml:trunk Nov 27, 2016
@gasche
Copy link
Member

gasche commented Nov 27, 2016

I went ahead and merged, thanks.

@christoph-cullmann
Copy link
Contributor Author

Thanks, I pinged Xavier if he has any feedback.
Hope that makes --with-frame-pointers work more reliable.

@xavierleroy
Copy link
Contributor

I'm always late to the party, sorry about that. But I'm OK with the change. It is a very good idea to always conform to the ABI, indeed!

camlspotter pushed a commit to camlspotter/ocaml that referenced this pull request Oct 17, 2017
PR#7417: ensure stack stays 16 bytes aligned
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
…l#930)

* crunch the playground assets as part of the build step of playground - build step of ocamlorg_static only copies the crunched asset file

* add static-file-digest script to tools/ folder to compute static file digests of playground assets in ocamlorg_static

* serve playground assets behind digest URLs to allow indefinite browser caching
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.

5 participants