www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: epi atari8.info



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5018


Adrian Matoga <epi atari8.info> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



buggy testcase, shame on me.

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