[Issue 5018] New: segfault / stack overflow when calling overriden Stream.writeBlock

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 8 07:27:45 PDT 2010


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

           Summary: segfault / stack overflow when calling overriden
                    Stream.writeBlock
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: epi at atari8.info


--- Comment #0 from Adrian Matoga <epi at atari8.info> 2010-10-08 07:27:18 PDT ---
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 at vbox:~/proj/xedisk/test$ ./t1
created
Segmentation fault

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


More information about the Digitalmars-d-bugs mailing list