runtime: _rt0_amd64_windows_lib stack frame not aligned, violates Microsoft x64 ABI #41075
The actual frame size of
I ran into this issue when I managed to run latest Go on Windows Server 2003 x64 (unsupported, yes I know).
Save and restore these registers looks strange for me.
This works for me. I don't think this change will break JNI usage, as mentioned in #30944.
The text was updated successfully, but these errors were encountered:
Is there any way for me to reproduce this problem? Regardless, please send your change, if you like, and I will review it.
We definitely need to leave 4 words on stack for AX, BX. DX and CX. I agree we don't need to restore BX. DX and CX. I am not familiar with BP here. But I suggest you leave code alone as is, just add code to align stack before CreateThread.
Windows amd64 calling convention requires 16-bytes aligned stack pointer. Before this patch, the real frame size is 0x48 (frame size) + 0x10 (frame pointer & return address), which does not satisfy the alignment requirement. _cgo_sys_thread_create eventually calls NtCreateThread, which receives a pointer to a ThreadContext structure allocated from (mis-aligned) stack, and may fail with STATUS_DATATYPE_MISALIGNMENT on some implementations. BP is saved/restored by prolog/epilog. AX, CX, DX are volatile, no need to save and restore. Fixes golang#41075