New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix issue 19497 - the program crash using dmd with -O, it works fine … #9113
Conversation
…without optimizations.
Thanks for your pull request and interest in making D better, @aG0aep6G! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "stable + dmd#9113" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me, but I'll wait for someone who understands what that code is actually doing. cc @WalterBright
@@ -443,7 +443,7 @@ void cdeq(ref CodeBuilder cdb,elem *e,regm_t *pretregs) | |||
postinc = e11.EV.E2.EV.Vint; | |||
if (e11.Eoper == OPpostdec) | |||
postinc = -postinc; | |||
getlvalue(cdb,&cs,e11,RMstore); | |||
getlvalue(cdb,&cs,e1,RMstore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 713 in 2ede66c
getlvalue(cdb,&cs,e11,RMstore | retregs); |
https://github.com/dlang/dmd/blob/master/src/dmd/backend/cgxmm.d#L257
have more or less the same code, should they be changed, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first one seems to have a workaround following it:
Lines 715 to 716 in 5cb179f
if (I64 && sz < 8) | |
cs.Irex &= ~REX_W; // incorrectly set by getlvalue() |
Blame leads to this commit: 521e68c. Unfortunately, there's hardly a hint as to what issue was fixed there. It looks like removing the workaround, and fixing the getlvalue
call instead, could work. But maybe we should first find/add a test that breaks without the workaround.
Regarding the one in cgxmm.d, I got nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first one seems to have a workaround following it:
This code triggers the workaround (Win64):
// REQUIRES: -O
int toStringz(string s) { return s.length > 0 ? s[0] : 0; }
private void toAStringz(in string[] a, int*az)
{
foreach (string s; a)
{
*az++ = toStringz(s);
}
}
void main()
{
string[1] sa = [ "abc" ];
int[2] tgt = 0x2a;
toAStringz(sa[], tgt.ptr);
assert(tgt[0] == 'a');
assert(tgt[1] == 0x2a);
}
It also passes if e11 is replaced by e1 instead of the workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the one in cgxmm.d, I got nothing.
It is hit by the same code when using float
, double
or __vector(T)
instead of int
, but doesn't seem to be affected by the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a commit that removes the workaround and adds your test.
Hi, I am George who submitted this bug. looking at the test case, just I wonder how it works. maybe I miss something!!
as q is a pointer to data[0], and we initialize the data[2] with 0x2A. Best Regards, |
We initialize both
That's right. After the increment,
There is no |
Thanks,
I didn’t pay attention to this line.
T[2] data = 0x2A;
it is initialization to the entire array :)
in my mind, I thought it was
data[2] = 0x2A
this is classic with me, as I am most of the time absent minded :)
Thanks a lot,
Wish a Merry Christmas and a Happy new year to you and to the entire D community,
Georges Toutoungis
… On Dec 24, 2018, at 6:12 PM, aG0aep6G ***@***.***> wrote:
as q is a pointer to data[0], and we initialize the data[2] with 0x2A.
We initialize both data[0] and data[1] to 0x2A. There is no data[2].
we put a value in data[0] using the pointer q, and incrementing q using q++.
then q should point to data[1] and not data[2].
That's right. After the increment, q points to data[1].
so how we test *q to content of data[2] which is 0x2A !!
There is no data[2]. I'm asserting that data[1] still contains 0x2A. With the bug, the assignment to data[0]also wrote over data[1] when T = int.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#9113 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AE0pt4DwgKGC1nuQSXB-m1JOsXITxdsJks5u8V9VgaJpZM4Zd5xs>.
|
Is this good to go now? |
The test suite for DMC++ has much more extensive code generator tests. Let me run that first. Also, now that the backend is in D, why aren't we getting the test coverage information for the back end? |
This change is crashing DMC++ when running its test suite. |
Too bad. Maybe the workaround from line 714 should be copied to the original location at line 446. |
Here's the test case that fails when this PR is added: |
That seems to work, too. But let's see #9146 fail the testers with the current version... |
ccompile.d doesn't fail on the auto-tester. @WalterBright Did it do that for you with the translated version or only for the C version? |
It did it for the translated version. At the moment, I cannot explain why it is failing on my system and not the autotester. |
The problems I was seeing with this were my own construction. |
…without optimizations.