8199 – stack is not aligned in finally block

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8199 - stack is not aligned in finally block
Summary: stack is not aligned in finally block
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 FreeBSD
: P2 major
Assignee: No Owner
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
Reported: 2012年06月05日 04:13 UTC by Martin Nowak
Modified: 2012年06月22日 00:01 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2012年06月05日 04:13:58 UTC
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 Martin Nowak 2012年06月14日 08:42:49 UTC
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 github-bugzilla 2012年06月22日 00:00:02 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/4e8cc86f5acc600511a4e12caab802b99d836c9b
fix Issue 8199 - stack is not aligned in finally block
Comment 3 github-bugzilla 2012年06月22日 00:00:44 UTC
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd
https://github.com/D-Programming-Language/dmd/commit/2b3a94d50f2d31410c9a1f70dfb5ead7f31b4a27
fix Issue 8199 - stack is not aligned in finally block


AltStyle によって変換されたページ (->オリジナル) /