Skip to content
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 20011, 17828 - crash or accept write operation on members of manifest constant structs #10115

Merged
merged 1 commit into from Jul 7, 2019

Conversation

ghost
Copy link

@ghost ghost commented Jun 30, 2019

This fixes a regression introduced by this fix as well as a related bug.

@dlang-bot
Copy link
Contributor

dlang-bot commented Jun 30, 2019

Thanks for your pull request and interest in making D better, @Basile-z! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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

Auto-close Bugzilla Severity Description
17828 normal [ICE] Internal error: ddmd/backend/cgcs.c 352 - CTFE appending to an array on a struct from a template
20011 regression [REG] modification of member of a manifest constant that's also a struct is allowed

Testing this PR locally

If 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#10115"

@ghost
Copy link
Author

ghost commented Jun 30, 2019

Considering that next minor release is about to be published, is this still good for stable ?

@thewilsonator
Copy link
Contributor

thewilsonator commented Jun 30, 2019

Yes, Please target stable.

@ghost ghost changed the title fix issue 20011, fix issue 17828 - crash or accept write operation on members of manifest constant structs fix issue 20011, 17828 - crash or accept write operation on members of manifest constant structs Jun 30, 2019
@ghost
Copy link
Author

ghost commented Jun 30, 2019

🤞 no conflicts 🤞

@ghost ghost requested review from ibuclaw and WalterBright as code owners June 30, 2019 14:06
@ghost ghost changed the base branch from master to stable June 30, 2019 14:06
@thewilsonator
Copy link
Contributor

No conflicts but you've got appveyor there, how old is the parent commit for that branch?

@ghost
Copy link
Author

ghost commented Jun 30, 2019

It must be an Appveyor issue because my local stable branch is up to date (9ddedc4)

@ghost
Copy link
Author

ghost commented Jun 30, 2019

I will force push otherwise automerge won't happen.

@kinke
Copy link
Contributor

kinke commented Jun 30, 2019

Auto-merge 13 mins after opening the PR? - I think this only patches over existing cracks. Handling this in modifiableLvalue() or so (I'm not familiar with this code here) seems more appropriate IMO.

@ghost
Copy link
Author

ghost commented Jun 30, 2019

The Lvalue logic is either botched or misused. I had to do this that way because the combination of the two bugs were driving me crazy but honestly this is not to bad: The error check is called in every overridden visit for an assign expression so although the Lvalue logic is not used this patch is clean. It's a leaf, easy to remove, it doesn't impose himself in the middle of something more complex.

@kinke
Copy link
Contributor

kinke commented Jun 30, 2019

The Lvalue logic is either botched or misused.

Yes, something is off since #9505, and that should be analyzed and fixed properly IMO, incl. fixing this:

void main()
{
    const x = 0;
    const p = &x;
    (cast() x) = 5; // wrongly const-folded to 0 = 5
    assert(*p == 5); // fails, still 0; that's what #9505 was supposed to fix
}

I guess that as soon as the root problem is understood, we don't need the special cases handled here (we didn't before #9505, did we? - edit: ah, one issue was from 2017, my bad).

@ghost
Copy link
Author

ghost commented Jun 30, 2019

Yes this fix is a bit special. There was this 2017 issue I was trying to understand and when minimizing by hand I found the smaller test case that was accepted and then only I realized there was a REG too. Now with this patch all the cases are handled.

My opinion on the root of the issue is that dotted expressions on enum were never really checked, only simple values (using STC.manifest) are.

Anyway I don't think this gonna make it for 2.087. PRs on stable branch are blocked by the project tester.
So no hurry. I chalenge other contributors to find a better fix. But fix the two issues too.

@wilzbach
Copy link
Member

Considering that next minor release is about to be published, is this still good for stable ?

Please be a bit careful when pushing to stable in those two days between the last release candidate and the actual release.

@thewilsonator
Copy link
Contributor

PRs on stable branch are blocked by the project tester.

built kite fails for unrelated reasons and is not required.

Copy link
Member

@WalterBright WalterBright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment

src/dmd/expressionsem.d Outdated Show resolved Hide resolved
@wilzbach
Copy link
Member

wilzbach commented Jul 1, 2019

built kite fails for unrelated reasons and is not required.

Come on. It is not unknown - it lacks a PR from druntime where the mangling was changed for Mecca. That one needs to be cherry-picked to stable.

src/dmd/expressionsem.d Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Jul 5, 2019

@WalterBright, can you see if the changes requested are applied correctly ?

kinke added a commit to kinke/dmd that referenced this pull request Jul 6, 2019
@ghost
Copy link
Author

ghost commented Jul 7, 2019

As seen in libasync through the project tester, fixed const ref function parameters which can accept members of structInit as the intention is not to modify.

@dlang-bot dlang-bot merged commit f905713 into dlang:stable Jul 7, 2019
@ghost ghost deleted the issue-20011-17828 branch July 7, 2019 08:24
kinke added a commit to kinke/dmd that referenced this pull request Aug 15, 2019
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Aug 15, 2019
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Sep 12, 2019
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Sep 27, 2019
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Jan 17, 2020
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the test cases are kept.
@anass-O
Copy link

anass-O commented Feb 29, 2020

@kinke did you ever revert this? Its causing more bugs and it seems to have introduced (partially) rvalues Bindable to const ref.

Also this is the cause of this regression.

Issues.dlang.org/show_bug.cgi?id=20608

@kinke
Copy link
Contributor

kinke commented Feb 29, 2020

It would be reverted in #10124, but that's blocked because of the Ocean lib, which needs a new release (waiting for months now).

kinke added a commit to kinke/dmd that referenced this pull request Aug 19, 2020
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Aug 19, 2020
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Aug 27, 2020
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Sep 2, 2020
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the (useful) test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Sep 2, 2020
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the (useful) test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Sep 2, 2020
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the (useful) test cases are kept.
kinke added a commit to kinke/dmd that referenced this pull request Sep 25, 2020
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the (useful) test cases are kept.
UplinkCoder pushed a commit to UplinkCoder/dmd that referenced this pull request Jan 5, 2021
Which just patched over some cracks wrt. accessing fields of struct
literals. Not a full revert, as the (useful) test cases are kept.
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.

8 participants