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 18871 & 18819 - DMD illegal hardware instruction crash #8260

Merged
merged 1 commit into from May 21, 2018
Merged

Fix Issue 18871 & 18819 - DMD illegal hardware instruction crash #8260

merged 1 commit into from May 21, 2018

Conversation

JinShil
Copy link
Contributor

@JinShil JinShil commented May 18, 2018

I'm still trying to create a reduced test case. When I print out ea.toChars(), I get this:

CallExp::interpret() _ArrayDtor([Vector(), Vector()])
1 ea = Vector[] [Vector(), Vector()]
2 ea = Vector[], arrayliteral [Vector(), Vector()]

If someone knows how to get a reduced test case from that. Please let me know.

@dlang-bot
Copy link
Contributor

dlang-bot commented May 18, 2018

Thanks for your pull request, @JinShil!

Bugzilla references

Auto-close Bugzilla Severity Description
18819 normal DMD compilation crash
18871 regression DMD "illegal hardware instruction" crash

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

@RazvanN7
Copy link
Contributor

RazvanN7 commented May 18, 2018

If someone knows how to get a reduced test case from that. Please let me know.

You can use dustmite [1].

I added the "Needs work" label due to the missing test.

[1] https://github.com/CyberShadow/DustMite/wiki

@JinShil
Copy link
Contributor Author

JinShil commented May 18, 2018

Figured it out. This is ready for review.

Copy link
Member

@dnadlinger dnadlinger left a comment

Choose a reason for hiding this comment

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

Is _ArrayDtor supposed to be a public API?

@JinShil
Copy link
Contributor Author

JinShil commented May 18, 2018

Is _ArrayDtor supposed to be a public API?

I don't think so, but so far, that's the only way I've been able to reproduce the bug without adding dependencies on std.experimental.allocator. I created that test based on what I saw in the compiler's lowering.

@JinShil
Copy link
Contributor Author

JinShil commented May 18, 2018

Actually, I should probably wait until dlang/druntime#2147 and #8067 are pulled and test this again.

@dnadlinger
Copy link
Member

dnadlinger commented May 18, 2018

Yep, I just tried your test case with _ArrayDtor replaced by a call to a copy (void foo(T)(T[] a) { foreach_reverse (ref T e; a) e.__xdtor(); }) in the same module, as well as from an imported module. I couldn't reproduce the crash.

Edit: Oh, of course, that code is in a special case for _Array{Postblit,Dtor}. Perhaps we can remove the special case entirely after #8067 is in?

@JinShil
Copy link
Contributor Author

JinShil commented May 18, 2018

Sorry, I don't understand. I'm not seeing the special case.

@dnadlinger
Copy link
Member

The whole if statement special-cases calls to the two functions I mentioned: https://github.com/dlang/dmd/pull/8260/files#diff-264b29261e215213d3026cd44003c2ebR4826

@dnadlinger
Copy link
Member

Either way, it would be great if we had a test case that didn't directly depend on _ArrayDtor – both to avoid it being unnecessarily brittle, and because the bug might actually lie elsewhere: Calling destructors directly on an ArrayLiteralExp seems somewhat weird.

@JinShil
Copy link
Contributor Author

JinShil commented May 19, 2018

Calling destructors directly on an ArrayLiteralExp seems somewhat weird

Yeah, that doesn't seem right, does it. I'll use digger to see if I can identify what caused the regression.

@JinShil
Copy link
Contributor Author

JinShil commented May 19, 2018

It appears the regression was caused by dlang/phobos#6411

I don't think this is the right fix. Calling a destructor on an array literal is nonsense.

@JinShil JinShil closed this May 19, 2018
@dnadlinger
Copy link
Member

Well, it's still a DMD bug, as it certainly shouldn't crash like that…

@JinShil
Copy link
Contributor Author

JinShil commented May 20, 2018

Ok, reopened in case someone wants to merge it.

@JinShil JinShil reopened this May 20, 2018
@JinShil JinShil changed the title Fix Issue 18871 - DMD illegal hardware instruction crash Fix Issue 18871 & 18819 - DMD illegal hardware instruction crash May 21, 2018
@JinShil
Copy link
Contributor Author

JinShil commented May 21, 2018

Fixed test case thanks to reduction in given in https://issues.dlang.org/show_bug.cgi?id=18819#c4

@dlang-bot dlang-bot merged commit d2d7cc1 into dlang:stable May 21, 2018
@JinShil JinShil deleted the fix_18871 branch May 30, 2018 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants