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

isFile() called with a nonexistant path crashes on Win64 #460

Closed
dymk opened this issue Aug 31, 2013 · 3 comments
Closed

isFile() called with a nonexistant path crashes on Win64 #460

dymk opened this issue Aug 31, 2013 · 3 comments
Assignees
Labels

Comments

@dymk
Copy link

dymk commented Aug 31, 2013

import std.stdio;
import std.file;

void main() {
    string path = "nonexistant";

    if(isFile(path) && exists(path)) {
        writeln("Is a file");
    }
}

Compiled with LLVM ~master and LDC ~master on Win64, the resulting binary will crash with very little debugging information. Debugging with MS Visual Studio is close to useless, as the location of the crash seems unrelated to isFile() or main().

The following information is printed to the console after the crash:
_d_throw_exception: RtlRaiseException failed. Perhaps this is the root of the problem (as I've experienced other crashes with similar symptoms as this, where the binary will simply crash and the stack trace will be near useless).

Building and running the same program with DMD:

$ dmd ldcio.d && ldcio.exe
std.file.FileException@std\file.d(922): testfile.tmp: The system cannot find the file specified.
----------------
0x004050BD
0x0040708C
0x004070C7
0x00406CC5
0x00405614
0x750B33AA in BaseThreadInitThunk
0x77379F72 in RtlInitializeExceptionChain
0x77379F45 in RtlInitializeExceptionChain

results in much more useful error message.

@dnadlinger
Copy link
Member

This is a Win64-only issue (the example works on MinGW/Win32). As you said, it is probably related to a problem in the exception handling implementation; Win64 SEH in LLVM is still worked on. (@redstar, assigning to you)

@ghost ghost assigned redstar Sep 21, 2013
@redstar
Copy link
Member

redstar commented Oct 8, 2013

LLVM -master does not support exception handling on Win64. Raising an exception results in this error.

If you are curious you can try my patch for EH on Win64 (see build instructions http://wiki.dlang.org/Building_and_hacking_LDC_on_Windows_using_MSVC). Currently, there is a compiler crash in one phobos module, but in general it works.

redstar pushed a commit that referenced this issue Sep 27, 2014
make Thread.sm_this a plain TLS value
@redstar
Copy link
Member

redstar commented Oct 19, 2014

Output of 0.15.0:

std.file.FileException@D:/OpenSource/ldc/ldc/runtime/phobos/std/file.d(919): nonexistant: The system cannot find the file specified.

@redstar redstar closed this as completed Oct 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants