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 18645 - DMD segmentation fault (Enum Initialization) #8072

Merged
merged 1 commit into from Mar 25, 2018
Merged

Fix Issue 18645 - DMD segmentation fault (Enum Initialization) #8072

merged 1 commit into from Mar 25, 2018

Conversation

JinShil
Copy link
Contributor

@JinShil JinShil commented Mar 23, 2018

No description provided.

@dlang-bot
Copy link
Contributor

dlang-bot commented Mar 23, 2018

Thanks for your pull request, @JinShil!

Bugzilla references

Auto-close Bugzilla Severity Description
18645 regression DMD segmentation fault

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#8072"

@JinShil JinShil changed the base branch from master to stable March 23, 2018 11:31
@JinShil JinShil added the Regression PRs that fix regressions label Mar 23, 2018
@mihails-strasuns-sociomantic
Copy link
Contributor

Thank you!

@mihails-strasuns-sociomantic
Copy link
Contributor

Tested on internal project - fixes the same problem there too.

@@ -2039,7 +2039,10 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
return errorReturn();

Expression eprev = emprev.value;
Type tprev = eprev.type.equals(em.ed.type) ? em.ed.memtype : eprev.type;
Type tprev =
eprev.type.ty == em.ed.type.ty // https://issues.dlang.org/show_bug.cgi?id=18645
Copy link
Member

Choose a reason for hiding this comment

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

How does this prevent a seg fault? Why is equals not working?

Copy link
Contributor Author

@JinShil JinShil Mar 25, 2018

Choose a reason for hiding this comment

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

It's trying to compare immutable(A) to A, causing equals to evaluate to false. That eventually causes problems later in the semantic pass resulting in a segfault at BinExp::setNoderefOperands.

When I compare the behavior of the compiler before the regression with the the current compiler, the change above is the precise point of diversion.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, that make sense. But the proposed fix doesn't work if the type is not a leaf type. I propose instead to use:

eprev.type.toHeadMutable().equals(em.ed.type.toHeadMutable())

This technique is used elsewhere in the front end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed. Thank you!

@WalterBright WalterBright merged commit faa6f89 into dlang:stable Mar 25, 2018
@JinShil JinShil deleted the fix_18645 branch April 24, 2018 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Regression PRs that fix regressions
Projects
None yet
5 participants