Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls_wrap: fix BIO leak on SSL error #1244

Closed
wants to merge 5 commits into from
Closed

Conversation

indutny
Copy link
Member

@indutny indutny commented Mar 24, 2015

@indutny
Copy link
Member Author

indutny commented Mar 24, 2015

cc @iojs/crypto

@mscdex mscdex added tls Issues and PRs related to the tls subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. labels Mar 24, 2015
@indutny
Copy link
Member Author

indutny commented Mar 24, 2015

Cecil,

May ask you to gist a test case that your are using?

Thank you!

On Monday, March 23, 2015, Cecil Worsley notifications@github.com wrote:

I found a pretty simple way to reproduce this. I created an HTTPS hello
world server and another process that produces hundreds of HTTPS get
requests/sec. In io.js I found the memory leaking exponentially but not in
node 0.10.33. Perhaps this could make it easier to test this issue? I'm not
a C++ guy but seems like a simple way to test the hypotheses?


Reply to this email directly or view it on GitHub
#1244 (comment).

@cworsley4
Copy link

Shoot, I accidentally deleted my comment. But sure, I can do that. I have been running the test for a few minutes and on node 0.10.33 memory climbs and then flattens out. io.js consumes multiple gigs after running for the same amount of time. I'll post the gist in a few.

@cworsley4
Copy link

Example gist: https://gist.github.com/cworsley4/458aa035f97672794e9f
You'll have to generate your own SSL Cert but this should pretty clearly.

@indutny
Copy link
Member Author

indutny commented Mar 24, 2015

@cworsley4 running it locally now, will report back here. @bnoordhuis do not let this stop you, though :) This commit is surely fixing some leak.

@indutny
Copy link
Member Author

indutny commented Mar 24, 2015

@cworsley4 just to make sure, what io.js version are you using?

@cworsley4
Copy link

I just duplicated the issue in 1.4.2, 1.5.1, and 1.6.2.

@indutny
Copy link
Member Author

indutny commented Mar 24, 2015

Interesting, I see some leaks in a client code... Will check it in a bit.

@cworsley4
Copy link

@indutny Leaks in the code I provided?

@indutny
Copy link
Member Author

indutny commented Mar 24, 2015

Not sure about containment yet, but I am able to confirm it with your test
case. Thank you!

On Tuesday, March 24, 2015, Cecil Worsley notifications@github.com wrote:

@indutny https://github.com/indutny Leaks in the code I provided?


Reply to this email directly or view it on GitHub
#1244 (comment).

@cworsley4
Copy link

I'm glad to hear it! Of course let us know what you find, or if I can provide anything else to the effort.

@indutny
Copy link
Member Author

indutny commented Mar 25, 2015

Update PR with a fix :) @cworsley4 thank you so much! You helped a lot.

@jasisk: this should fix your leak, guys ;)

cc @iojs/crypto

@indutny
Copy link
Member Author

indutny commented Mar 25, 2015

@jasisk: at least I have lots of hope for this

@jasisk
Copy link

jasisk commented Mar 25, 2015

Haha. 👍 Deploying.

Always call `Done` on the WriteWrap, and ensure that `EncOut` will
consume all data in clear_in_ and invoke queued callbacks.

Fix: nodejs#1075
@cworsley4
Copy link

Do you guys think this PR will make it into #1252?

@@ -335,6 +339,9 @@ void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) {
// Commit
NodeBIO::FromBIO(wrap->enc_out_)->Read(nullptr, wrap->write_size_);

// Ensure that the progress will be maed and `InvokeQueued` will be called
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/maed/made/ and can you end the sentence with a dot?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

@indutny
Copy link
Member Author

indutny commented Mar 25, 2015

CI: https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/373/

Thanks for the comments!

@jasisk
Copy link

jasisk commented Mar 25, 2015

Redeploying. 😀

@indutny
Copy link
Member Author

indutny commented Mar 25, 2015

The CI: appears to be blue.

@bnoordhuis
Copy link
Member

LGTM

indutny added a commit that referenced this pull request Mar 25, 2015
Fix: #1075
PR-URL: #1244
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
indutny added a commit that referenced this pull request Mar 25, 2015
Always call `Done` on the WriteWrap, and ensure that `EncOut` will
consume all data in clear_in_ and invoke queued callbacks.

Fix: #1075
PR-URL: #1244
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@indutny
Copy link
Member Author

indutny commented Mar 25, 2015

Landed in e74b5d2, 2ccc8f3. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants