Bug 1953 – BufferedFile seek and flush dumps 4gb to disk

Status
RESOLVED
Resolution
WONTFIX
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-03-27T06:47:00Z
Last change time
2015-11-03T19:11:36Z
Assigned to
nobody
Creator
regan

Comments

Comment #0 by regan — 2008-03-27T06:47:54Z
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; }
Comment #1 by andrei — 2015-11-03T19:11:36Z
It's unlikely this D1 issue will get worked on. If it applies to D2 as well and/or if anyone plans to work on it, please reopen.