Thread overview
[Issue 9598] New: Cannot use moveFront on MapResult!(lambda, ByLine!(char, char))
Feb 27, 2013
Chris Cain
Feb 27, 2013
Maxim Fomin
Feb 27, 2013
Chris Cain
Oct 25, 2013
safety0ff.bugz
February 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9598

           Summary: Cannot use moveFront on MapResult!(lambda,
                    ByLine!(char, char))
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: zshazz@gmail.com


--- Comment #0 from Chris Cain <zshazz@gmail.com> 2013-02-26 22:33:51 PST ---
Using DMD 2.062 with no command line arguments other than the source file in question

I have the following (expected valid) code:

---

import std.stdio, std.file, std.algorithm, std.conv, std.range;

void main() {
    dirEntries("data", "*.out", SpanMode.shallow)
        .map!(e => File(e.name).byLine()
            .map!(line => text(line))() // compile error
        )()
        .array()
        .nWayUnion() // line 9
        .copy(stdout.lockingTextWriter);
}

---

Which produces errors. Error 1 is a compile-time failure producing the following message:

---
C:\D\dmd2\windows\bin\..\..\src\phobos\std\range.d(6695): Error: static assert
"Cannot move front of a range with a postblit and an rvalue front."
C:\D\dmd2\windows\bin\..\..\src\phobos\std\container.d(3797):
instantiated from here: moveFront!(MapResult!(__lambda4, ByLine!(char,
char))[])
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(10526):
instantiated from here: BinaryHeap!(MapResult!(__lambda4, ByLine!(char,
char))[], compFront)
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(10562):
instantiated from here: NWayUnion!("a < b", MapResult!(__lambda4, ByLine!(char,
char))[])
D:\[snip]\src\reducedCase.d(9):        instantiated from here: nWayUnion!("a <
b", MapResult!(__lambda4, ByLine!(char, char))[])

---

If I change the code to this:

---

import std.stdio, std.file, std.algorithm, std.conv, std.range;

void main() {
    dirEntries("data", "*.out", SpanMode.shallow)
        .map!(e => File(e.name).byLine()
            .map!text() // Compiles, runtime error
        )()
        .array()
        .nWayUnion() // line 9
        .copy(stdout.lockingTextWriter);
}

---

Then the code compiles, but produces a runtime error (when files are in data directory and named *.out):

object.Error: Access Violation
----------------
0x00429674
0x004294FF
0x7730B459 in LdrRemoveLoadAsDataTable
0x7730B42B in LdrRemoveLoadAsDataTable
0x772C0133 in KiUserExceptionDispatcher
0x0018F6E8
0x0018F738
----------------


Specifically, these errors apply to MapResult!(lambda, ByLine!(char, char)).
For instance, using a string[][] as an array and applying a .map!text() as
above, there is no problem for either case.

---

import std.stdio, std.file, std.algorithm, std.conv, std.range;

void main() {
    [["abc", "cbd"], ["dce", "efg"]]
        .map!(e =>
            //e.map!text()               // OK
            e.map!(line => text(line))() // OK
        )()
        .array()
        .nWayUnion()
        .copy(stdout.lockingTextWriter);
}

---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9598


Maxim Fomin <maxim@maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim@maxim-fomin.ru
           Severity|normal                      |major


--- Comment #1 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-02-27 04:49:11 PST ---
Can confirm on linux. What's interesting is that executable crashes during garbage collection which I haven't met before.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9598


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #2 from bearophile_hugs@eml.cc 2013-02-27 05:02:04 PST ---
(In reply to comment #0)

> Then the code compiles, but produces a runtime error (when files are in data directory and named *.out):
> 
> object.Error: Access Violation
> ----------------
> 0x00429674
> 0x004294FF
> 0x7730B459 in LdrRemoveLoadAsDataTable
> 0x7730B42B in LdrRemoveLoadAsDataTable
> 0x772C0133 in KiUserExceptionDispatcher
> 0x0018F6E8
> 0x0018F738
> ----------------

In such cases it's better to _also_ compile with -g, that shows an error in void* gc.gcx.GC.mallocNoSync(uint, uint, uint*).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9598



--- Comment #3 from Chris Cain <zshazz@gmail.com> 2013-02-27 05:13:20 PST ---
(In reply to comment #2)
> In such cases it's better to _also_ compile with -g, that shows an error in void* gc.gcx.GC.mallocNoSync(uint, uint, uint*).

Good point, thanks for the information. Here's what it's giving me on my system (running Windows 7 64-bit):

object.Error: Access Violation
----------------
0x0042C7C4 in char[][] core.sys.windows.stacktrace.StackTrace.trace()
0x0042C64F in core.sys.windows.stacktrace.StackTrace
core.sys.windows.stacktrace
.StackTrace.__ctor()
0x7730B459 in LdrRemoveLoadAsDataTable
0x7730B42B in LdrRemoveLoadAsDataTable
0x772C0133 in KiUserExceptionDispatcher
0x002B1ECB
----------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9598


safety0ff.bugz <safety0ff.bugz@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |safety0ff.bugz@gmail.com


--- Comment #4 from safety0ff.bugz <safety0ff.bugz@gmail.com> 2013-10-25 13:48:08 PDT ---
The access violation case seems to have been fixed sometime between 2.063.2 and current git version.

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