Thread overview
Crash when iterating over files with foreach and std.file.dirEntries on Windows?
Nov 16, 2015
Jeremy DeHaan
Nov 16, 2015
Johannes Pfau
Nov 16, 2015
Jeremy DeHaan
Nov 16, 2015
Vincent R
Nov 17, 2015
Jeremy DeHaan
Nov 17, 2015
Jeremy DeHaan
Nov 17, 2015
Jeremy DeHaan
November 16, 2015
I'm wondering if anyone has experienced a crash when using dirEntries to iterate over files. This is for the Windows 32 bits build of gdc from the gdc downloads page and it happens for both the 5.2.0 and 4.9.3 gcc versions (I haven't tried any others). It works correctly for the 64 bit builds though.

I'm wondering if this is a known issue (I couldn't find anything) or if I should get a minimal example going. Crash seems to happen when exiting a foreach loop.
November 16, 2015
Am Mon, 16 Nov 2015 03:08:39 +0000
schrieb Jeremy DeHaan <dehaan.jeremiah@gmail.com>:

> I'm wondering if anyone has experienced a crash when using dirEntries to iterate over files. This is for the Windows 32 bits build of gdc from the gdc downloads page and it happens for both the 5.2.0 and 4.9.3 gcc versions (I haven't tried any others). It works correctly for the 64 bit builds though.
> 
> I'm wondering if this is a known issue (I couldn't find anything) or if I should get a minimal example going. Crash seems to happen when exiting a foreach loop.

I think somebody already reported this. The windows builds are unsupported right now and there are likely many similar issues. I hope we'll have stable MinGW builds at the end of this year.
November 16, 2015
On Monday, 16 November 2015 at 09:31:22 UTC, Johannes Pfau wrote:
> Am Mon, 16 Nov 2015 03:08:39 +0000
> schrieb Jeremy DeHaan <dehaan.jeremiah@gmail.com>:
>
>> I'm wondering if anyone has experienced a crash when using dirEntries to iterate over files. This is for the Windows 32 bits build of gdc from the gdc downloads page and it happens for both the 5.2.0 and 4.9.3 gcc versions (I haven't tried any others). It works correctly for the 64 bit builds though.
>> 
>> I'm wondering if this is a known issue (I couldn't find anything) or if I should get a minimal example going. Crash seems to happen when exiting a foreach loop.
>
> I think somebody already reported this. The windows builds are unsupported right now and there are likely many similar issues. I hope we'll have stable MinGW builds at the end of this year.

Should I file an issue in the bugzilla just in case? And if it makes you feel better, this is the first issue I've encountered with the MinGW builds.
November 16, 2015
On Monday, 16 November 2015 at 15:34:13 UTC, Jeremy DeHaan wrote:
> Should I file an issue in the bugzilla just in case? And if it makes you feel better, this is the first issue I've encountered with the MinGW builds.

yes you should and please post the code you have used because I would be curious to reproduce it myself.

Thanks
November 17, 2015
On Monday, 16 November 2015 at 22:47:27 UTC, Vincent R wrote:
> On Monday, 16 November 2015 at 15:34:13 UTC, Jeremy DeHaan wrote:
>> Should I file an issue in the bugzilla just in case? And if it makes you feel better, this is the first issue I've encountered with the MinGW builds.
>
> yes you should and please post the code you have used because I would be curious to reproduce it myself.
>
> Thanks

Absolutely. I'm going to spend some time narrowing this down and making sure I know what exactly is causing it before I post any code though.
November 17, 2015
On Tuesday, 17 November 2015 at 05:25:27 UTC, Jeremy DeHaan wrote:
> On Monday, 16 November 2015 at 22:47:27 UTC, Vincent R wrote:
>> On Monday, 16 November 2015 at 15:34:13 UTC, Jeremy DeHaan wrote:
>>> Should I file an issue in the bugzilla just in case? And if it makes you feel better, this is the first issue I've encountered with the MinGW builds.
>>
>> yes you should and please post the code you have used because I would be curious to reproduce it myself.
>>
>> Thanks
>
> Absolutely. I'm going to spend some time narrowing this down and making sure I know what exactly is causing it before I post any code though.

After minimizing my code, I am now wondering if it has something to do with ranges in general or if it is related to just dirEntries. This will cause a crash:

module test;

import std.stdio;
import std.file;


void main(string[] args)
{
	writeln("Testing");

	auto directoryEntries = dirEntries("C:\\", SpanMode.shallow);

	writeln("fails?");

}//crash on exiting the scope


And if we try to do something with the range we get a crash earlier.


module test;

import std.stdio;
import std.file;
import std.array;


void main(string[] args)
{
	writeln("Testing");

	auto directoryEntries = array(dirEntries("C:\\", SpanMode.shallow)); //crash here

	writeln("fails?");//never printed

}
November 17, 2015
Just to reiterate, this happens with 32 bit gdc only. The 64 bit gdc works correctly for this.