[Issue 1953] New: BufferedFile seek and flush dumps 4gb to disk
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 27 04:47:55 PDT 2008
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 at digitalmars.com
ReportedBy: regan at 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;
}
--
More information about the Digitalmars-d-bugs
mailing list