Thread overview
Error: 0xc0000005, Dmd Win 64
Mar 08, 2013
Michael
Mar 08, 2013
Michael
Mar 09, 2013
Rainer Schuetze
Mar 09, 2013
Michael
Mar 09, 2013
Rainer Schuetze
Mar 09, 2013
Michael
Mar 09, 2013
Brad Roberts
Mar 09, 2013
Michael
Mar 08, 2013
Michael
March 08, 2013
Code works good on Win 32, but at start on Win 64 I got:

>Exception code: 0xc0000005
>Fault offset: 0x00000000000132c5

void main(string[] args)
{
    auto workDir = "build_tmp";
    auto currDir = getcwd();
    string[] src;
    string[] obj;
    string cfg = "build.json";
    Compiler compiler;
    DirEntry[] files;

    if (args.length > 1 && !args[1].empty)
        if (exists(args[1]))
            cfg = args[1];

    try
    {
        compiler = cfg.readCompilerInfo();
    }
    catch (Exception e)
    {
        writeln(e.msg);
    }

    if (compiler is null)
        return;

    if (!exists(compiler.srcDestination))
    {
        writeln("Not found: <" ~ compiler.srcDestination ~ ">.");
        return;
    }

    files = dirEntries(compiler.srcDestination, "*.d", SpanMode.depth).array;

    if (files is null)
    {
        writeln("No sources.");
        return;
    }

    foreach(f; files)
    {
        src ~= absolutePath(f.name);
        obj ~= buildNormalizedPath(workDir, setExtension(f.name, "obj"));
    }

    for (size_t i = 0; i < src.length; i ++)
    {
        if (!obj[i].dirName().exists())
            obj[i].dirName().mkdirRecurse();

        compiler.compile(src[i], obj[i]).executeInShell();
    }

    compiler.build(obj).executeInShell();
}
March 08, 2013
On Friday, 8 March 2013 at 13:25:42 UTC, Michael wrote:
> Code works good on Win 32, but at start on Win 64 I got:
>
>>Exception code: 0xc0000005
>>Fault offset: 0x00000000000132c5

If "auto currDir = getcwd();" commented, error is not appear.

getcwd broken on win 8 x64?
March 08, 2013
So, there is problem in toUTF8 in std.utf "toUTF8(in wchar[] s)".

string cwd()// copied from phobos
{
    writeln("start");
    import core.sys.windows.windows;
    writeln("buff");
    wchar[] ret = new wchar[10240];
    writeln("call");
    auto n = GetCurrentDirectoryW(to!DWORD(ret.length), ret.ptr);
    writeln("return");
    return ret[0 .. n].to!string();
}

Works as expected on both win32 and win64.
March 09, 2013

On 08.03.2013 18:00, Michael wrote:
> On Friday, 8 March 2013 at 13:25:42 UTC, Michael wrote:
>> Code works good on Win 32, but at start on Win 64 I got:
>>
>>> Exception code: 0xc0000005
>>> Fault offset: 0x00000000000132c5
>
> If "auto currDir = getcwd();" commented, error is not appear.
>
> getcwd broken on win 8 x64?

I don't see it crashing over here. What version of dmd are you using? Do you have some extra long cwd or some non-standard characters in your path?
March 09, 2013
> I don't see it crashing over here. What version of dmd are you using? Do you have some extra long cwd or some non-standard characters in your path?

Usual path is "D:\Dev\M1xA\D"
OS: Win 8 Pro 64 bit
DMD 2.062
VS 2012 Express for Desktop

Code from Phobos successfully compiles, but crashes on 64 bit.
March 09, 2013
This code works good.

string cwd()
{
    import core.sys.windows.windows;
    wchar[] ret = new wchar[10240];
    auto n = GetCurrentDirectoryW(to!DWORD(ret.length), ret.ptr);
    return ret[0 .. n].to!string();
}

Also similar problem/crash occurs in "dirEntries" on 64 bit.



March 09, 2013

On 09.03.2013 09:42, Michael wrote:
>> I don't see it crashing over here. What version of dmd are you using?
>> Do you have some extra long cwd or some non-standard characters in
>> your path?
>
> Usual path is "D:\Dev\M1xA\D"
> OS: Win 8 Pro 64 bit
> DMD 2.062
> VS 2012 Express for Desktop
>
> Code from Phobos successfully compiles, but crashes on 64 bit.

I can reproduce it with VS2012, but not with VS2008 (cannot test VS2010 atm). It seems some incompatibility with the MS runtime library LIBCMT.lib.
March 09, 2013
Crash also occurs when

int[] a;
a.length = 10;

So, it's maybe something wrong with ms c runtime of VS 2012.

Just installed Update 2 for VS 2012, not helps.
March 09, 2013
On 3/9/2013 7:11 AM, Michael wrote:
> Crash also occurs when
> 
> int[] a;
> a.length = 10;
> 
> So, it's maybe something wrong with ms c runtime of VS 2012.
> 
> Just installed Update 2 for VS 2012, not helps.

Please make sure that a bug report is filed:

  http://d.puremagic.com/issues/

Thanks,
Brad