D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17646 - dmd segfaults on missing foreach body in import
Summary: dmd segfaults on missing foreach body in import
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: uplink.coder
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2017-07-13 14:05 UTC by John Colvin
Modified: 2017-08-16 13:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description John Colvin 2017-07-13 14:05:46 UTC
$ cat ut.d
int main()
{
        runTests!"";
}

int runTests(Modules...)() {
        import reflection;
        allTestData!Modules;
}

$ cat reflection.d
struct TestData {} const(TestData)[] allTestData(MOD_STRINGS...)()
{
        foreach (i; MOD_STRINGS)
}
$ gdb -q dmd
Reading symbols from dmd...done.
(gdb) r -o- ut.d
Starting program: dmd -o- ut.d
DMD v2.075.0-b4-102-gf189b2d08-dirty DEBUG
reflection.d(4): Error: found '}' instead of statement

Program received signal SIGSEGV, Segmentation fault.
0x0000000000637b63 in StatementSemanticVisitor::visit(ForeachStatement*) (this=0x7fffffff98d8, fs=0x7ffff6cb22d0) at ddmd/statementsem.d:742
742                     st.push(fs._body.syntaxCopy());
(gdb) p fs._body
$1 = (ddmd.statement.Statement *) 0x0


For some reason semantic is going ahead despite syntax having failed?
Comment 1 uplink.coder 2017-07-13 14:07:41 UTC
That should be an easy fix.
Comment 2 uplink.coder 2017-07-13 16:15:18 UTC
https://github.com/dlang/dmd/pull/6992
Comment 3 Vladimir Panteleev 2017-07-15 04:47:57 UTC
FWIW, no segfault before https://github.com/dlang/dmd/pull/708.
Comment 4 github-bugzilla 2017-08-07 11:55:13 UTC
Commits pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/b25be458bebe59f773faf1c2f7bed57d9836ddea
Fix Issue 17646 - dmd segfaults on missing [tuple] foreach body in import

https://github.com/dlang/dmd/commit/9009c1f4e0798a5c6b1d4c37515e616f97a240a0
add regression test for Issue 17646

https://github.com/dlang/dmd/commit/a3927bd30b0bfbda2a1fe0e127b011e9c3470051
Merge pull request #6993 from UplinkCoder/fix17646_on_stable

Fix Issue 17646 - dmd segfaults on missing [tuple] foreach body in import
merged-on-behalf-of: Martin Nowak <code@dawg.eu>
Comment 5 github-bugzilla 2017-08-16 13:20:00 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/b25be458bebe59f773faf1c2f7bed57d9836ddea
Fix Issue 17646 - dmd segfaults on missing [tuple] foreach body in import

https://github.com/dlang/dmd/commit/9009c1f4e0798a5c6b1d4c37515e616f97a240a0
add regression test for Issue 17646

https://github.com/dlang/dmd/commit/a3927bd30b0bfbda2a1fe0e127b011e9c3470051
Merge pull request #6993 from UplinkCoder/fix17646_on_stable