Skip to content

Fix issue 20052 - SIMD 32 bytes segfault#10178

Merged
dlang-bot merged 3 commits intodlang:stablefrom
SSoulaimane:fix20052
Jul 15, 2019
Merged

Fix issue 20052 - SIMD 32 bytes segfault#10178
dlang-bot merged 3 commits intodlang:stablefrom
SSoulaimane:fix20052

Conversation

@SSoulaimane
Copy link
Member

@SSoulaimane SSoulaimane commented Jul 15, 2019

issue 20052.

When doing runtime stack alignment, the stack frame must be saved otherwise the return address will be lost.

For example:
the following function

struct y { __vector(long[4]) v; }
y get()
{
    y a;
    return a;
}

generated the following instructions:

and    rsp,0xffffffffffffffe0
xor    eax,eax
mov    QWORD PTR [rdi],rax
mov    QWORD PTR [rdi+0x8],rax
mov    QWORD PTR [rdi+0x10],rax
mov    QWORD PTR [rdi+0x18],rax
mov    rax,rdi
ret

Notice there is no RBP. When the return procedure is reached, the ret instruction pops the return address from the stack which has been altered earlier by the alignment instruction, which crashes the program.

This patch does two things: 1) make sure BP is stored, and a proper leave procedure is used whenever there is runtime stack alignent. 2) omit runtime alignment when all symbols are dead.

@SSoulaimane SSoulaimane force-pushed the fix20052 branch 3 times, most recently from c47fd0c to f485d1a Compare July 15, 2019 03:04
@SSoulaimane SSoulaimane changed the title Fix issue 20052 - SIMD 32 bytes segfault on windows 64 Fix issue 20052 - SIMD 32 bytes segfault Jul 15, 2019
@SSoulaimane SSoulaimane marked this pull request as ready for review July 15, 2019 06:04
@dlang-bot dlang-bot merged commit b561bf5 into dlang:stable Jul 15, 2019
wilzbach pushed a commit to wilzbach/dmd that referenced this pull request Jul 30, 2019
Fix issue 20052 - SIMD 32 bytes segfault
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants