Issue 15441 - dmd segfaults using std.experimental.ndslice
Summary: dmd segfaults using std.experimental.ndslice
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: ice, pull
Depends on:
Blocks:
 
Reported: 2015-12-14 08:25 UTC by Stefan Frijters
Modified: 2016-03-19 20:21 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Stefan Frijters 2015-12-14 08:25:13 UTC
Using the 0.8.3 dub version of std.experimental.ndslice, dmd 2.069.1 segfaults on the following reduced code:

import std.experimental.ndslice;

void main() {
	Slice!(3, double*) force = new double[60].sliced(3, 4, 5);
	// Wrong foreach params. dmd failed with exit code -11.
	foreach(p, e; force)
	{
	}
}

See also ttxfuwiesghpbnlwytfr@forum.dlang.org.
Comment 1 John Colvin 2015-12-14 09:35:28 UTC
Further reduced:

% cat test.d
struct Slice
{
    auto front()() {}
}

void foo()
{
    Slice force;
    foreach(p, e; force){}
}

% dmd test.d
[1]    18478 segmentation fault (core dumped)  dmd test.d

% lldb dmd    
(lldb) target create "dmd"
Current executable set to 'dmd' (x86_64).
(lldb) r test.d
Process 18567 launched: '/usr/local/bin/dmd' (x86_64)
Process 18567 stopped
* thread #1: tid = 0xa054c, 0x000000010014c011 dmd`ForeachStatement::semantic(Scope*) + 11601, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x000000010014c011 dmd`ForeachStatement::semantic(Scope*) + 11601
dmd`ForeachStatement::semantic:
->  0x10014c011 <+11601>: movq   (%r13), %rax
    0x10014c015 <+11605>: callq  *0x1b8(%rax)
    0x10014c01c <+11612>: testq  %rax, %rax
    0x10014c01f <+11615>: je     0x10014c031               ; <+11633>
(lldb) bt all
* thread #1: tid = 0xa054c, 0x000000010014c011 dmd`ForeachStatement::semantic(Scope*) + 11601, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x000000010014c011 dmd`ForeachStatement::semantic(Scope*) + 11601
    frame #1: 0x0000000100146d4d dmd`CompoundStatement::semantic(Scope*) + 517
    frame #2: 0x00000001000ba66a dmd`FuncDeclaration::semantic3(Scope*) + 4962
    frame #3: 0x000000010006244a dmd`Module::semantic3() + 90
    frame #4: 0x00000001000f6cc9 dmd`tryMain(unsigned long, char const**) + 28905
    frame #5: 0x0000000100003b9b dmd`_Dmain + 47
    frame #6: 0x0000000100219da8 dmd`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 40
    frame #7: 0x0000000100219ced dmd`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 45
    frame #8: 0x0000000100219d4d dmd`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 45
    frame #9: 0x0000000100219ced dmd`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 45
    frame #10: 0x0000000100219c63 dmd`_d_run_main + 499
    frame #11: 0x0000000100003c38 dmd`main + 20
    frame #12: 0x00000001000021b8 dmd`_start + 230
    frame #13: 0x00000001000020d1 dmd`start + 33
Comment 2 Jack Stouffer 2015-12-14 17:30:45 UTC
Same issue on OS X, so changing this to all OS's.
Comment 4 github-bugzilla 2016-01-03 18:34:54 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a52cb5f786fd9ff2a1db7d497fa6cf65ef3d5646
fix Issue 15441 - dmd segfaults using std.experimental.ndslice

https://github.com/D-Programming-Language/dmd/commit/ef054013cd42d931c84a3706b0f365b125712bd4
Merge pull request #5309 from 9rnsr/fix15441

Issue 15441 - dmd segfaults using std.experimental.ndslice
Comment 5 github-bugzilla 2016-03-19 20:21:27 UTC
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a52cb5f786fd9ff2a1db7d497fa6cf65ef3d5646
fix Issue 15441 - dmd segfaults using std.experimental.ndslice

https://github.com/D-Programming-Language/dmd/commit/ef054013cd42d931c84a3706b0f365b125712bd4
Merge pull request #5309 from 9rnsr/fix15441