Bug 10136 – Segfault on File struct, map and array
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2013-05-22T12:49:00Z
Last change time
2015-06-09T01:31:22Z
Assigned to
nobody
Creator
maxim
Comments
Comment #0 by maxim — 2013-05-22T12:49:55Z
From forum thread:
import std.array;
import std.algorithm;
import std.stdio;
void main() {
auto names = ["file1.txt", "file2.txt", "file3.txt"]; // let these files exist
auto files = names.map!(f => File(f, "r"))().array();
}
This segfaults.
Some notes:
1) Without .array it works.
2) In valgrind there is assertion failure in swap phobos function which bails out when lhs pointer == rhs pointer. These equal pointers are passed by struct File.opAssign, which, in turn, is called by emplace, which, in turn, is called by array phobos function. Probably there is typo error or wrong-code in this chain.
3) In gdb there is segfault inside GC internals after main() exit which likely to be irrelevant since memory is corrupted before exit.
Comment #1 by stephan.schiffels — 2013-05-22T16:38:56Z
*** Issue 10137 has been marked as a duplicate of this issue. ***
Comment #2 by bearophile_hugs — 2013-08-20T12:56:52Z
In DMD 2.064alpha on Windows32 this seems to work to me.
Comment #3 by maxim — 2013-08-20T13:01:49Z
(In reply to comment #2)
> In DMD 2.064alpha on Windows32 this seems to work to me.
It still segfaults in linux.
Comment #4 by monarchdodra — 2013-08-28T02:05:19Z
(In reply to comment #3)
> (In reply to comment #2)
> > In DMD 2.064alpha on Windows32 this seems to work to me.
>
> It still segfaults in linux.
This is works for with 2.064 alpha on a linux 64.