Skip to content

Fix FillQWord_SSE2 stack usage.

Rika requested to merge runewalsh/source:i386-fq into main

AS IT TURNS OUT (sorry (gangsters don’t say “sorry”)), my FillQWord from !544 (merged) messes with the stack because it receives

[esp .. esp + 3] = return address, [esp + 4 .. esp + 11] = value     (1)

from which it reasonably expects to return by ret $8, but it also jumps from this state straightly to the common SSE branch that expects

[esp .. esp + 3] = return address                                    (2)

and returns by ret. This code causes stack overflow (though even one FillQWord should corrupt pops that follow):

procedure FillSomeQWords;
var
	q: array[0 .. 9] of uint64;
	rep: int32;
begin
	for rep := 1 to 128 * 1024 * 1024 do
		FillQWord(q, length(q), 1234);
end;

begin
	FillSomeQWords;
end.

This MR adapts (1) to (2) as required (assuming FPC_SYSTEM_STACKALIGNMENT16 is irrelevant idk is it...).

Edited by Rika

Merge request reports