Bug 8199 – stack is not aligned in finally block

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
FreeBSD
Creation time
2012-06-05T04:13:00Z
Last change time
2012-06-22T00:01:51Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2012-06-05T04:13:58Z
cat > bug.d << CODE void checkAlign() { asm { naked; mov RDI, RSP; and RDI, 0xF; cmp RDI, 0x8; je Lpass; hlt; Lpass: ret; } } void foo() { } void main() { checkAlign(); scope(exit) checkAlign(); foo(); } CODE dmd -run bug ---- The scope exit pushes the address of the return block onto the stack which breaks the stack alignment.
Comment #1 by code — 2012-06-14T08:42:49Z
https://github.com/D-Programming-Language/dmd/pull/988 This bug affects all calls from a finally block that require an aligned stack. The "optimization" is also a huge performance hog. Abusing return as indirect jump always incurs a branch misprediction.
Comment #2 by github-bugzilla — 2012-06-22T00:00:02Z
Comment #3 by github-bugzilla — 2012-06-22T00:00:44Z