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 21164 - segfault on incomplete static if #11585

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

UplinkCoder
Copy link
Member

With this change, when evaluating a static if, we now check for the existence of an static if
condition and will only proceed if there is one.

@MoonlightSentinel
Copy link
Contributor

MoonlightSentinel commented Aug 17, 2020

Why is static if} not a parser error in this particular example?

@UplinkCoder
Copy link
Member Author

@MoonlightSentinel it is.
extra-files/test21164d.d(3): Error: (expression) expected following static if
however since this is triggered within the semantic of function body within a template instance, it does not immediately abort.

@MoonlightSentinel
Copy link
Contributor

MoonlightSentinel commented Aug 17, 2020

[...] it does not immediately abort.

Put that one poorly, I'm not sure why it even attempts to do semantic on AB which caused parser errors. That doesn't sound like a good idea,...

EDIT: Maybe this needs some earlier error propagation?

@UplinkCoder
Copy link
Member Author

Maybe this needs some earlier error propagation?

@MoonlightSentinel perhaps that would be the proper fix.
However I'd like to see if this one will at least compile ... seems like REQUIRED_ARGS doen't work as intended though?

@UplinkCoder
Copy link
Member Author

Thanks @MoonlightSentinel

@UplinkCoder UplinkCoder force-pushed the fix_21164 branch 2 times, most recently from 6fa4bf5 to 293b59f Compare August 17, 2020 16:54
@UplinkCoder UplinkCoder changed the title {WIP }Fix 21164 Fix Issue 21164 Aug 17, 2020
@UplinkCoder UplinkCoder marked this pull request as ready for review August 17, 2020 17:11
@UplinkCoder UplinkCoder requested a review from Geod24 as a code owner August 17, 2020 17:11
@Geod24
Copy link
Member

Geod24 commented Aug 17, 2020

As usual, please give a proper title to both PR and commits.
Remember the Contributing guidelines include an article about good commit messages.

@ghost
Copy link

ghost commented Aug 20, 2020

ping @UplinkCoder, can you polish the formal aspect of this PR ? this should not take more than 5 minutes.

@UplinkCoder
Copy link
Member Author

@Geod24 What exactly would you want to read, as far as I can see the information needed is in the commit message.

@ghost
Copy link

ghost commented Sep 4, 2020

The message of the first commit must be fix issue 21164 - segfault on incomplete static if. Then the title of the PR should also be set to that, for now it's not descriptive. It's a bit like a click bait.

@UplinkCoder
Copy link
Member Author

UplinkCoder commented Sep 4, 2020 via email

@Geod24
Copy link
Member

Geod24 commented Sep 5, 2020

@UplinkCoder : Come on, I even linked an article. All one have to do is to read it.

@UplinkCoder UplinkCoder changed the title Fix Issue 21164 Fix Issue 21164 - segfault on incomplete static if Sep 5, 2020
@dlang-bot
Copy link
Contributor

dlang-bot commented Sep 5, 2020

Thanks for your pull request, @UplinkCoder!

Bugzilla references

Auto-close Bugzilla Severity Description
21164 normal segfault on incomplete static if

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#11585"

@UplinkCoder UplinkCoder force-pushed the fix_21164 branch 2 times, most recently from c9ea955 to 6684b53 Compare September 5, 2020 16:12
@UplinkCoder
Copy link
Member Author

@Geod24 I assume you mean the line length, fixed now.

@UplinkCoder
Copy link
Member Author

@MoonlightSentinel this fails on windows because of the different path separators, in the error message.
How do I fix this?

@MoonlightSentinel
Copy link
Contributor

MoonlightSentinel commented Sep 7, 2020

Seems like a bug with the new path handling. You could omit the additional import path and use imports.xxxx directly (it still segfaults).

EDIT:
It failed to change

fail_compilation/imports\test21164d.d(3): Error: (expression) expected following `static if`

into

fail_compilation\imports\test21164d.d(3): Error: (expression) expected following `static if`

instead.

I'll have a look.

@wilzbach
Copy link
Member

wilzbach commented Sep 7, 2020

Seems like a bug with the new path handling. You could omit the additional import path and use imports.xxxx directly (it still segfaults).

EDIT:
It failed to change

fail_compilation\imports\test21164d.d(3): Error: (expression) expected following `static if`

into

fail_compilation/imports\test21164d.d(3): Error: (expression) expected following `static if`

I'll have a look.

I had a look to and I couldn't reproduce it locally.

@UplinkCoder
Copy link
Member Author

This is worrying.
The fix is rather important.

@MoonlightSentinel
Copy link
Contributor

I would suggest using the workaround until we figure out what went wrong here.

Also, did you find anything regarding the missing error propagation?

@UplinkCoder
Copy link
Member Author

I would suggest using the workaround until we figure out what went wrong here.

Done.

Also, did you find anything regarding the missing error propagation?

Unfortunately no.

@MoonlightSentinel
Copy link
Contributor

MoonlightSentinel commented Sep 7, 2020

Actually, DMD's completely random path handling on windows is to blame here.

d_do_test correctly translates the expected output:

fail_compilation/imports/test21164d.d(3): Error: (expression) expected following `static if`
fail_compilation/imports/test21164d.d(3): Error: found `}` instead of statement
fail_compilation/test21164.d(11): Error: template instance `test21164a.D!(R!(O(), 1))` error instantiating

into

fail_compilation\imports\test21164d.d(3): Error: (expression) expected following `static if`
fail_compilation\imports\test21164d.d(3): Error: found `}` instead of statement
fail_compilation\test21164.d(11): Error: template instance `test21164a.D!(R!(O(), 1))` error instantiating

But dmd seems to copy the import path, hence keeping the / on windows ...

@UplinkCoder
Copy link
Member Author

@thewilsonator can you slap an auto-merge on?

@UplinkCoder UplinkCoder added the Merge:72h no objection -> merge The PR will be merged if there are no objections raised. label Sep 8, 2020
@UplinkCoder UplinkCoder mentioned this pull request Sep 10, 2020
@Geod24 Geod24 changed the base branch from master to stable September 11, 2020 01:54
With this change we now check for the existance
of a static if condition and will only proceed
if there is one.

The test doesn't use the imports folder due to problems
with path changes on the error message for windows.
@Geod24 Geod24 added Merge:auto-merge and removed Merge:72h no objection -> merge The PR will be merged if there are no objections raised. labels Sep 11, 2020
@Geod24
Copy link
Member

Geod24 commented Sep 11, 2020

Rebased & squashed, retargeting stable so you get it in the next release.

@UplinkCoder
Copy link
Member Author

Thanks @Geod24!

@UplinkCoder
Copy link
Member Author

Auto-merge toggled on

@UplinkCoder
Copy link
Member Author

The mac failure on the autotester is unrelated.

@thewilsonator
Copy link
Contributor

autotester is required on stable.

@wilzbach
Copy link
Member

Hold your horses. Auto-tester will restart the build automatically.

@UplinkCoder
Copy link
Member Author

The build on osx just timed out a second time.
What's going on?

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.

6 participants