Summary: Access Violation with optimized build when using
                    memory-mapped file
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos

--- Comment #0 from Andrej Mitrovic <> 2012-01-07 
19:53:30 PST ---
I am *not* sure if the following code is correct, it's copied from another
source and I've never used memory-mapped files before:

module test;

import std.algorithm;
import std.mmfile;

void readfile(string filename)
    string[] lines;
    auto fFile   = new MmFile(filename);
    auto fBuffer = cast(char*)(fFile[].ptr);
    auto fLength = cast(size_t)fFile.length;
    auto textData = fBuffer[0 .. fLength];

    foreach (char[] line; splitter(textData, "\n"))
        lines ~= line.idup;

void main() {

This only happens when reading large files like std.datetime:
$ dmd test.d && test.exe

$ dmd -O test.d && test.exe
object.Error: Access Violation

ddbg says:
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d:2885 (0x00402b23)

That's why I've labeled is as a Phobos bug. But maybe it's a bug in the user

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to