[Issue 18794] Compiling with -O causes runtime segfault

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 25 05:21:34 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18794

--- Comment #5 from ag0aep6g <ag0aep6g at gmail.com> ---
(In reply to ag0aep6g from comment #1)
> bitIdx is a DWORD at rbp-0x10. But later a QWORD is read from there and used
> in the bt instruction. So that reads garbage from the stack. The garbage can
> be controlled by prep.
It's probably worth pointing out that the result is still wrong even when prep
zeroes the high bits. An int can't just be used as the low half of a long.

(In reply to hsteoh from comment #2)
> Just a side-note that although in my own environment, the problem can be
> reproduced with -O alone, apparently in some other environments specifying
> both -O and -profile is necessary to trigger the bug.
(In reply to Jonathan M Davis from comment #3)
> I can reproduce this on FreeBSD x86_64 with master, but I have to use
> -profile with -O. -O by itself doesn't trigger it for me.
You guys are talking about the original code, right? The behavior relies on
stack garbage, so it makes sense that it isn't reproducible everywhere. If you
happen to have zeroes at the particular stack address, you won't see a
segfault.

The modified code in comment #1 should segfault consistently with just -O (and
without -inline).

--


More information about the Digitalmars-d-bugs mailing list