D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5018 - segfault / stack overflow when calling overriden Stream.writeBlock
Summary: segfault / stack overflow when calling overriden Stream.writeBlock
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-08 07:27 UTC by Adrian Matoga
Modified: 2010-10-29 08:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Adrian Matoga 2010-10-08 07:27:18 UTC
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 Adrian Matoga 2010-10-29 08:06:48 UTC
buggy testcase, shame on me.