You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But Rust FFI mistakenly passes a, b, c, d, e and lower 8bytes of f in registers. This is wrong
according to abi.pdf, page 20:
If there are no registers available for any eightbyte of an argument, the whole
argument is passed on the stack. If registers have already been assigned for some
eightbytes of such an argument, the assignments get reverted.
The text was updated successfully, but these errors were encountered:
I’ve (probably) hit this in html5ever-python. I worked around it by adding a dummy usize padding argument to my callback so that (presumably) a struct would not be split between registers and the stack.
A comment about this by Armin Rigo, Python-CFFI and PyPy developer:
Argh, the x86-64 calling convention is full of obscure details. Fwiw, cffi uses libffi to do that. In PyPy the JIT does it directly but only if the arguments are only plain integers/pointers/floats; for more complicated cases involving structs it falls back to libffi too.
On linux x86_64, FFI passes arguments in wrong order if the function has more than 6 arguments, with struct (passed by value) mixed.
Reproduce
bug.c
bug.rs
Rust version
Expected output:
1 2 3 4 5
10 20 30 40
6 7
Actual output:
1 2 3 4 5
30 40 6 32740
10 7
Reason
Only 6 arguments can be passed by registers (see http://www.x86-64.org/documentation/abi.pdf).
In the above example,
a, b, c, d, e, g
should be passed in registers,f & h
should be passed on stack.But Rust FFI mistakenly passes
a, b, c, d, e
and lower 8bytes off
in registers. This is wrongaccording to abi.pdf, page 20:
The text was updated successfully, but these errors were encountered: