Bug 3424 – Ref counting still doesn't work for std.stdio.File

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-10-20T09:22:00Z
Last change time
2015-06-09T01:26:55Z
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2009-10-20T09:22:29Z
If this can't be fixed in short order it should at least be documented so that people don't rely on the ref counting and auto closing. Here's a test case to show it doesn't work. This fails on both Windows and Linux. import std.stdio, std.file; void main() { std.file.write("foo.txt", "stuff"); foreach(i; 0..1_000_000) { openStuff(); // Throws too many files error rather quickly. } } void openStuff() { File myFile = File("foo.txt"); // Not automatically closed. }
Comment #1 by andrei — 2009-10-20T13:03:22Z
(In reply to comment #0) > If this can't be fixed in short order it should at least be documented so that > people don't rely on the ref counting and auto closing. Here's a test case to > show it doesn't work. This fails on both Windows and Linux. > > import std.stdio, std.file; > > void main() { > std.file.write("foo.txt", "stuff"); > foreach(i; 0..1_000_000) { > openStuff(); // Throws too many files error rather quickly. > } > } > > void openStuff() { > File myFile = File("foo.txt"); > // Not automatically closed. > } I'm glad to report I just fixed this and committed stdio.d.
Comment #2 by leandro.lucarella — 2009-10-20T17:29:50Z
Your commit, r1300, also removes some opSlice(): @@ -736,10 +740,4 @@ /// Range primitive implementations. - ByLine!(Char, Terminator) opSlice() - { - return this; - } - - /// Ditto bool empty() const { Is this intended? If so, it would be nice if you could apply the changes in two different commits (if they are really unrelated, as I think they are; if not, please ignore this comment :). I'm sorry to say this here I guess it's not the place, but I don't know of a better place.
Comment #3 by andrei — 2009-10-20T17:38:19Z
(In reply to comment #2) > Your commit, r1300, also removes some opSlice(): > > @@ -736,10 +740,4 @@ > > /// Range primitive implementations. > - ByLine!(Char, Terminator) opSlice() > - { > - return this; > - } > - > - /// Ditto > bool empty() const > { > > > Is this intended? If so, it would be nice if you could apply the changes in two > different commits (if they are really unrelated, as I think they are; if not, > please ignore this comment :). > > I'm sorry to say this here I guess it's not the place, but I don't know of a > better place. For a brief period, Walter required opSlice for foreach to work. He subsequently changed that, so I clean up that stuff when I get the opportunity.
Comment #4 by leandro.lucarella — 2009-10-20T17:50:14Z
(In reply to comment #3) > (In reply to comment #2) > > Your commit, r1300, also removes some opSlice(): > > > > @@ -736,10 +740,4 @@ > > > > /// Range primitive implementations. > > - ByLine!(Char, Terminator) opSlice() > > - { > > - return this; > > - } > > - > > - /// Ditto > > bool empty() const > > { > > > > > > Is this intended? If so, it would be nice if you could apply the changes in two > > different commits (if they are really unrelated, as I think they are; if not, > > please ignore this comment :). > > > > I'm sorry to say this here I guess it's not the place, but I don't know of a > > better place. > > For a brief period, Walter required opSlice for foreach to work. He > subsequently changed that, so I clean up that stuff when I get the opportunity. Ok, that comment would be an excellent commit message for a separated commit removing the opSlice() ;) Thanks for the clarification.
Comment #5 by braddr — 2009-10-20T18:26:12Z
The two @@BUG@@ comments that are still there.. is there still a bug? If so, what is the bug number?