http://d.puremagic.com/issues/show_bug.cgi?id=7244

           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
        AssignedTo: nob...@puremagic.com
        ReportedBy: andrej.mitrov...@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrov...@gmail.com> 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() {
    readfile("datetime.d");
}

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

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

ddbg says:
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at
std.algorithm.find!(pred,ubyte[],ubyte[]).find
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d:2885 (0x00402b23)
thread(2408)

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to