Bug 5018 – segfault / stack overflow when calling overriden Stream.writeBlock

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-10-08T07:27:00Z
Last change time
2010-10-29T08:06:48Z
Assigned to
nobody
Creator
adrian

Comments

Comment #0 by adrian — 2010-10-08T07:27:18Z
I'm not sure whether this is an issue with compiler or Phobos. A testcase close to minimal: import std.stdio; import std.stream; class S : Stream { override size_t readBlock(void* buffer, size_t size) { (cast(ubyte*) buffer)[0 .. size] = 0; return size; } override size_t writeBlock(const void* buffer, size_t size) { writefln("%s", size); return size; } override ulong seek(long offset, SeekPos whence) { throw new SeekException("seek not implemented"); } } void main() { auto s = new S; writeln("created"); ubyte[] z = [0, 1, 2, 3]; auto w = s.write(z); writeln(w); } Saved as t1.d and compiled using command "dmd t1.d". On windows 7 (64-bit) outputs: D:\proj\d\utest6>t1 created object.Error: Stack Overflow On ubuntu 10.04 (32-bit) outputs: epi@vbox:~/proj/xedisk/test$ ./t1 created Segmentation fault
Comment #1 by adrian — 2010-10-29T08:06:48Z
buggy testcase, shame on me.