Skip to content

Make sure the i386 sysv stack is aligned #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2023
Merged

Make sure the i386 sysv stack is aligned #218

merged 1 commit into from
Jan 26, 2023

Conversation

nielsdos
Copy link
Contributor

@nielsdos nielsdos commented Jan 25, 2023

SysV ABI requires a stack alignment of 16 bytes. Currently, for i386 with SysV ABI, the trampoline function is entered with an unaligned stack. This causes problems for the context-function that is jumped to as its stack is also unaligned. This causes a crash for our use-case because the context function contains an SSE instruction which reads from the stack. The SSE instruction requires the correct alignment. Fix it by changing the 0x2c offset to 0x30, such that the stack remains aligned.

Related issue in this repo: #210

For reference:
php/php-src#10407 (comment) and php/php-src#10398

SysV ABI requires a stack alignment of 16 bytes. Currently, for i386
with SysV ABI, the trampoline function is entered with an unaligned
stack. This causes problems for the context-function that is jumped to
as its stack is also unaligned. This causes a crash for our use-case
because the context function contains an SSE instruction which reads
from the stack. The SSE instruction requires the correct alignment.
Fix it by changing the 0x2c offset to 0x30, such that the stack remains
aligned.
@olk olk merged commit be937bd into boostorg:develop Jan 26, 2023
@olk
Copy link
Member

olk commented Jan 26, 2023

ty

algitbot pushed a commit to alpinelinux/aports that referenced this pull request Feb 5, 2024
Without this patch, boost's `make_fcontext` does not correctly
align the stack pointer on i386. This will cause software
to SIGSEV when using `movaps` and similar instructions which
require 16-byte stack alignment.

This fixes the Nix check() on x86 (see !60218).

See:

* boostorg/context#210
* boostorg/context#218
bell-sw pushed a commit to bell-sw/alpaquita-aports that referenced this pull request Feb 7, 2024
[ commit b602563d3e3a4428c07eacbfde85e6e0fbe1c0f4 ]

Without this patch, boost's `make_fcontext` does not correctly
align the stack pointer on i386. This will cause software
to SIGSEV when using `movaps` and similar instructions which
require 16-byte stack alignment.

This fixes the Nix check() on x86 (see !60218).

See:

* boostorg/context#210
* boostorg/context#218
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.

2 participants