Align stack correctly when initializing a context #230
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
my_context_spawn
, assuming the allocated stack pointer is 16-bye aligned (as it will be from malloc, etc), align the stack correctly before calling the target function of the context.For i686 platform, The Linux ABI requires that the stack is aligned on a 16-byte boundary at the time that a call is made, and the compiler attempts to maintain that alignment by adjusting the stack as required to meet the alignment requirements for data, and any subsequent calls.
This is particularly important when compiling for i386 platform with -msse2, The compiler can use SSE2 instructions like
movaps
, This instruction will actually fault on unalgned access. This causes the mariadb test suite to fail with the following error, for example:In this case, the eventual crash is in openssl code, but this is a conseqeunce of a
movaps
instruction inBIO_f_buffer
acting on an unaligned stack location, which is in turn a result of the unaligned stack from my_context_spawn. Any use of SSE2 instructions requiring alignment will fail in the same way