fs: fix fd leak in ReadStream.destroy()#56
Conversation
|
existing tests all pass with this change? and do you know the reasoning behind the addition here (i.e. have you done a blame here or on readable-stream to figure that out?) |
|
@rvagg all existing tests passed, yes. The change was part of this commit: nodejs/node-v0.x-archive@44b308b There is no indication for the purpose except that it's a regression that causes code that calls The original issue was acknowledged as a bug, but it was told there needed to be a test, but how to do that cross platform was never answered, since Node.js does not give access to the list of all open file descriptors. |
|
Here's your test case, pull it in to this PR: rvagg@3d89deb |
|
removed a |
|
@rvagg i love you |
|
lgtm, obviously, need a review from someone else and then I'll deal with the multi-commits appropriately |
d7e65ff to
185d11c
Compare
|
Also, the test and patch should come in one commit. |
|
I'm not sure what exactly we are fixing with this, btw. The
Additional argument: I'm generally -1 for this patch, unless a good argument will appear here. +1 for fixing the documentation of fs module and making a note about |
|
@indutny here is the bug:
TL;DR the |
|
@dougwilson v0.12 streams are not calling destroy, AFAIK. And your fix is targeting v0.12 branch. |
Clearly, it is: https://github.com/iojs/io.js/blob/v0.12/lib/stream.js#L89 |
|
@dougwilson am I right that this is the legacy streams API, and is not used by |
|
Actually v0.10 streams are not calling destroy either, but I didn't check it that much. |
|
I'm not sure what you're asking, I'm sorry. This is what I'm doing: var ws = fs.createWriteStream(...)
stream.pipe(ws)Now |
|
@dougwilson why that stream is using legacy |
|
@rvagg 's test could be simplified to this: var fs = require('fs');
var assert = require('assert');
var fdClosed = false;
fs.close = (function(close) {
return function() {
fdClosed = true;
close.apply(fs, arguments);
}
})(fs.close);
fs.createReadStream(__filename).destroy();
process.on('exit', function() {
assert(fdClosed);
});It will fail without and succeed with this patch. But it's implementation-dependent, that's what worried me. I mean, it tests that |
|
@indutny it's what I'm being given by old 0.8-style code from a vendor, as they are inheriting from the old
|
|
@rlidwka see the thing I am talking about is that |
In this case it should probably be renamed to But what the accepted method to close a stream is? As far as I know, |
|
@rlidwka yes, it is |
|
@dougwilson I don't see any reason to keep |
|
@rlidwka not sure about removing it either. What are your thoughts on this @bnoordhuis ? |
This is 100% fine with me for 0.12. Can we do anything for 0.10, perhaps, pretty please? |
* [Refactoring] change taint to _taint on buffer
* [Refactor] Added _taint in unit tests
* [Feature] Added method for buffer
* [Test] Buffer.new() test for each encoding
* [Test] Buffer.from() tests
* [Test] Buffer.new() tests
* [Test] Buffer.new() tests for one string + each encoding
* [Test] Buffer.new() tests for concatenated ascii and utf8 encoding
* [Test] Buffer.new() test enhanced for utf8 encoding
* [Test] Buffer.new() tests for hex (ascii) encoding
* [Test] Buffer.new() removed bug in unit tests
* [Test] Buffer.new() tests for hex encoding with utf8 character
* [Test] Buffer.new() unit tests for base64 encoding
* [Test] Buffer.new() unit tests for base64 unicode encoding
* [Test] Buffer.new() refactoring for utf8 + ascii encoding
* [Buffer] Reactor taint propagation toString and slice
* [Buffer] Remove previously inserted newlines
* [Buffer] Taint propagation for Buffer.prototype.toString('hex')
* [Test] Buffer.new() unit tests for utf8 encoding
* [Feature] Buffer.alloc() keep taint
* [Feature] Buffer.alloc() keep (sub-)taint for hex encoding
* [Test] Buffer.fill() unit tests
* [Feature] Buffer.write() ascii/uft8 taint propagation
* [Test] Buffer.concat() unit tests
* Buffer.write() refactored
* Â[Feature] apply Taint to Partial Buffer
* [Feature] Keep taint outsite taint ranges for write/fill
* [Fix] Buffer.concat() taint propagation
* [Merge] buffer refactoring
* [Refactoring] Final buffer status
* [Feature] Final status of buffer
* [Feature] Final refactored buffer api status
* [Refactoring] change taint to _taint on buffer
* [Refactor] Added _taint in unit tests
* [Feature] Added method for buffer
* [Test] Buffer.new() test for each encoding
* [Test] Buffer.from() tests
* [Test] Buffer.new() tests
* [Test] Buffer.new() tests for one string + each encoding
* [Test] Buffer.new() tests for concatenated ascii and utf8 encoding
* [Test] Buffer.new() test enhanced for utf8 encoding
* [Test] Buffer.new() tests for hex (ascii) encoding
* [Test] Buffer.new() removed bug in unit tests
* [Test] Buffer.new() tests for hex encoding with utf8 character
* [Test] Buffer.new() unit tests for base64 encoding
* [Test] Buffer.new() unit tests for base64 unicode encoding
* [Test] Buffer.new() refactoring for utf8 + ascii encoding
* [Buffer] Reactor taint propagation toString and slice
* [Buffer] Remove previously inserted newlines
* [Buffer] Taint propagation for Buffer.prototype.toString('hex')
* [Test] Buffer.new() unit tests for utf8 encoding
* [Feature] Buffer.alloc() keep taint
* [Feature] Buffer.alloc() keep (sub-)taint for hex encoding
* [Test] Buffer.fill() unit tests
* [Feature] Buffer.write() ascii/uft8 taint propagation
* [Test] Buffer.concat() unit tests
* Buffer.write() refactored
* Â[Feature] apply Taint to Partial Buffer
* [Feature] Keep taint outsite taint ranges for write/fill
* [Fix] Buffer.concat() taint propagation
* [Merge] buffer refactoring
* [Refactoring] Final buffer status
* [Feature] Final status of buffer
* [Feature] Final refactored buffer api status
* [Refactoring] change taint to _taint on buffer
* [Refactor] Added _taint in unit tests
* [Feature] Added method for buffer
* [Test] Buffer.new() test for each encoding
* [Test] Buffer.from() tests
* [Test] Buffer.new() tests
* [Test] Buffer.new() tests for one string + each encoding
* [Test] Buffer.new() tests for concatenated ascii and utf8 encoding
* [Test] Buffer.new() test enhanced for utf8 encoding
* [Test] Buffer.new() tests for hex (ascii) encoding
* [Test] Buffer.new() removed bug in unit tests
* [Test] Buffer.new() tests for hex encoding with utf8 character
* [Test] Buffer.new() unit tests for base64 encoding
* [Test] Buffer.new() unit tests for base64 unicode encoding
* [Test] Buffer.new() refactoring for utf8 + ascii encoding
* [Buffer] Reactor taint propagation toString and slice
* [Buffer] Remove previously inserted newlines
* [Buffer] Taint propagation for Buffer.prototype.toString('hex')
* [Test] Buffer.new() unit tests for utf8 encoding
* [Feature] Buffer.alloc() keep taint
* [Feature] Buffer.alloc() keep (sub-)taint for hex encoding
* [Test] Buffer.fill() unit tests
* [Feature] Buffer.write() ascii/uft8 taint propagation
* [Test] Buffer.concat() unit tests
* Buffer.write() refactored
* Â[Feature] apply Taint to Partial Buffer
* [Feature] Keep taint outsite taint ranges for write/fill
* [Fix] Buffer.concat() taint propagation
* [Merge] buffer refactoring
* [Refactoring] Final buffer status
* [Feature] Final status of buffer
* [Feature] Final refactored buffer api status
Original commit message:
Merged: [deoptimizer] Stricter checks during deoptimization
Revision: 506e893b812e03dbebe34b11d8aa9d4eb6869d89
BUG=chromium:1161357
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true
R=mythria@chromium.org
(cherry picked from commit 44d052c19df0801fafdf2be54c899db65e79c67a)
Change-Id: I97b69ae11d85bc0acd4a0c7bd28e1b692433de80
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2616219
Reviewed-by: Mythri Alle <mythria@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Original-Commit-Position: refs/branch-heads/8.8@{#23}
Cr-Original-Branched-From: 2dbcdc105b963ee2501c82139eef7e0603977ff0-refs/heads/8.8.278@{#1}
Cr-Original-Branched-From: 366d30c99049b3f1c673f8a93deb9f879d0fa9f0-refs/heads/master@{#71094}
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2649571
Reviewed-by: Victor-Gabriel Savu <vsavu@google.com>
Commit-Queue: Achuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/branch-heads/8.6@{nodejs#56}
Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}
Refs: v8/v8@ad2c5da
Original commit message:
Merged: [deoptimizer] Stricter checks during deoptimization
Revision: 506e893b812e03dbebe34b11d8aa9d4eb6869d89
BUG=chromium:1161357
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true
R=mythria@chromium.org
(cherry picked from commit 44d052c19df0801fafdf2be54c899db65e79c67a)
Change-Id: I97b69ae11d85bc0acd4a0c7bd28e1b692433de80
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2616219
Reviewed-by: Mythri Alle <mythria@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Original-Commit-Position: refs/branch-heads/8.8@{#23}
Cr-Original-Branched-From: 2dbcdc105b963ee2501c82139eef7e0603977ff0-refs/heads/8.8.278@{#1}
Cr-Original-Branched-From: 366d30c99049b3f1c673f8a93deb9f879d0fa9f0-refs/heads/master@{#71094}
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2649571
Reviewed-by: Victor-Gabriel Savu <vsavu@google.com>
Commit-Queue: Achuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/branch-heads/8.6@{nodejs#56}
Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}
Refs: v8/v8@ad2c5da
Original commit message:
Merged: [deoptimizer] Stricter checks during deoptimization
Revision: 506e893b812e03dbebe34b11d8aa9d4eb6869d89
BUG=chromium:1161357
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true
R=mythria@chromium.org
(cherry picked from commit 44d052c19df0801fafdf2be54c899db65e79c67a)
Change-Id: I97b69ae11d85bc0acd4a0c7bd28e1b692433de80
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2616219
Reviewed-by: Mythri Alle <mythria@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Original-Commit-Position: refs/branch-heads/8.8@{#23}
Cr-Original-Branched-From: 2dbcdc105b963ee2501c82139eef7e0603977ff0-refs/heads/8.8.278@{#1}
Cr-Original-Branched-From: 366d30c99049b3f1c673f8a93deb9f879d0fa9f0-refs/heads/master@{#71094}
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2649571
Reviewed-by: Victor-Gabriel Savu <vsavu@google.com>
Commit-Queue: Achuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/branch-heads/8.6@{#56}
Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}
Refs: v8/v8@ad2c5da
PR-URL: #38275
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>

this is a file descriptor leak PR that was opened in joyent/node for a while but had no traction. please pull this or give us directions on the tests!
nodejs/node-v0.x-archive#8178
/cc @rlidwka @dougwilson