Description
We encountered this with WebRender, where we exposed a method in Rust to the Gecko, and the last parameters supplied appeared random on the Rust side. I made a reduced test case adapted from it that you can grab at:
https://github.com/aosmond/myrustffi
It is a very simple test case where the C++ program puts all the parameters on the stack, prints the expected values of some of them, and calls the Rust method. The Rust method prints the values it received. We have enough parameters to fill up the registers used in the calling convention, and once we get to pushing things on the stack, it goes wrong. You can see from the output that they mismatch.
./build-debug.sh && ./run-debug.sh
outputs
c++ expect width=7 height=8
c++ expect slice=9 10 11 12
c++ expect outset=13.000000 13.100000 13.200000 13.300000
c++ expect repeat h=0 v=0
got rust image 6 width 7 height 8
got rust slice SideOffsets { top: 9, right: 10, bottom: 11, left: 12 }
got rust outset LayoutGeometry { top: 0.0, left: 0.0, width: 0.0, height: 0.0 }
got rust repeat h=26 v=58
Note that the earlier parameters are correct, but the last 3 (outset, repeat h and repeat v) are all incorrect.