digitalmars.D.bugs - [Issue 1953] New: BufferedFile seek and flush dumps 4gb to disk
- d-bugmail puremagic.com (51/51) Mar 27 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1953
http://d.puremagic.com/issues/show_bug.cgi?id=1953 Summary: BufferedFile seek and flush dumps 4gb to disk Product: D Version: 2.012 Platform: PC OS/Version: Windows Status: NEW Severity: major Priority: P2 Component: Phobos AssignedTo: bugzilla digitalmars.com ReportedBy: regan netmail.co.nz The following code creates a 4gb+ size file on disk. This appears to be the result of a signed/unsigned problem inside a flush call somewhere in std.stream import std.stdio; import std.stream; import std.file; import std.random; int main() { // Create small file auto f = new BufferedFile("test", FileMode.OutNew); int size = 50000; for(int i = 0; i < size; i++) f.write('a'); f.close; // Open and modify f = new BufferedFile("test", FileMode.In | FileMode.Out); ulong total = getSize("test"); long block = total/1000; long offset; long bytes; Random gen; writefln("Total: %d,%d", total, block); for(int i = 0; i < 2; i++) { offset = uniform!(long)(gen, 0L, block); bytes = uniform!(long)(gen, 0L, block); writefln("Seek : %d,%d,%d", f.position, offset, bytes); f.seekCur(offset); writefln("Mod : %d,%d", f.position, bytes); for(long j = 0; j < bytes; j++) f.write('\0'); writefln("Done : %d", f.position); } writefln("Close: %d", f.position); f.close; writefln("Done"); return 0; } --
Mar 27 2008