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: do not leak WriteWrap objects #1090

Closed
wants to merge 4 commits into from

Conversation

indutny
Copy link
Member

@indutny indutny commented Mar 7, 2015

Kill WriteWrap instances that are allocated in tls_wrap.cc internally.

Fix: #1075

cc @iojs/crypto @bnoordhuis

This should fix it once and forever :) (hopefully)

Kill WriteWrap instances that are allocated in `tls_wrap.cc` internally.

Fix: nodejs#1075
@indutny
Copy link
Member Author

indutny commented Mar 7, 2015

@Fishrock123
Copy link
Member

Odd, looks like there were a lot of git fetch failures..

@indutny
Copy link
Member Author

indutny commented Mar 7, 2015

Yeah :(

@rvagg
Copy link
Member

rvagg commented Mar 7, 2015

Weird. Can someone try again and double check that the branch actually exists?

@indutny
Copy link
Member Author

indutny commented Mar 7, 2015

@rvagg:

/tmp $ git clone --depth=1 git://github.com/indutny/io.js -b fix/paypal-leak-for-sure
Cloning into 'io.js'...
remote: Counting objects: 12288, done.
remote: Compressing objects: 100% (10161/10161), done.
remote: Total 12288 (delta 3046), reused 7068 (delta 1593), pack-reused 0
Receiving objects: 100% (12288/12288), 30.36 MiB | 2.65 MiB/s, done.
Resolving deltas: 100% (3046/3046), done.
Checking connectivity... done.
/tmp $

@bnoordhuis
Copy link
Member

It probably gets confused by the slash in the branch name.

@indutny
Copy link
Member Author

indutny commented Mar 7, 2015

@bnoordhuis I always do them in branches, seems to be very unlikely

@rvagg
Copy link
Member

rvagg commented Mar 7, 2015

I did change the way it grabs branches recently so the slash thing is possible. Perhaps try without and see.

@rvagg
Copy link
Member

rvagg commented Mar 7, 2015

I take that back .. I only changed it on the nightly and release jobs, the pr-multi one just checks out $branch

@rvagg
Copy link
Member

rvagg commented Mar 7, 2015

cleaned out the existing workspaces on most of the build machines and it seems happy now https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/260/

@indutny
Copy link
Member Author

indutny commented Mar 7, 2015

@rvagg : seems to be mostly green, except aborted ubuntu1410 build.

@indutny
Copy link
Member Author

indutny commented Mar 7, 2015

LGTY @bnoordhuis ?

@rvagg
Copy link
Member

rvagg commented Mar 7, 2015

14.10 slave back online and running

@@ -314,6 +315,8 @@ void TLSWrap::EncOut() {

void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) {
TLSWrap* wrap = req_wrap->wrap()->Cast<TLSWrap>();
req_wrap->~WriteWrap();
delete[] reinterpret_cast<char*>(req_wrap);
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest moving the placement new and delete logic into New and Dispose methods, like I did just now with FSReqWrap in src/node_file.cc. Having the same logic repeated five times throughout the file is not good software engineering.

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -308,11 +303,9 @@ int StreamBase::WriteString(const FunctionCallbackInfo<Value>& args) {
CHECK_EQ(count, 1);
}

storage = new char[sizeof(WriteWrap) + storage_size + 15];
Copy link
Member Author

Choose a reason for hiding this comment

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

@bnoordhuis do you think this is still relevant?

Copy link
Member Author

Choose a reason for hiding this comment

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

If not - we may want to skip this 15 byte thing above too.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is no relevant anymore. PTAL at follow-up commit.

@indutny
Copy link
Member Author

indutny commented Mar 7, 2015

@bnoordhuis and one more patch for your fun :)

@bnoordhuis
Copy link
Member

LGTM, the only thing I would perhaps change is the use of int instead of size_t.

@indutny
Copy link
Member Author

indutny commented Mar 7, 2015

Thanks, will do. One more build, just to be sure: https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/261/

indutny added a commit that referenced this pull request Mar 7, 2015
Kill WriteWrap instances that are allocated in `tls_wrap.cc` internally.

Fix: #1075
PR-URL: #1090
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
indutny added a commit that referenced this pull request Mar 7, 2015
Encapsulate allocation/disposal of `WriteWrap` instances into the
`WriteWrap` class itself.

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

indutny commented Mar 7, 2015

Landed in 7f4c95e, fe36076 .

@indutny indutny closed this Mar 7, 2015
@indutny indutny deleted the fix/paypal-leak-for-sure branch March 7, 2015 23:51
@indutny
Copy link
Member Author

indutny commented Mar 7, 2015

Thank you, everyone!

@rvagg rvagg mentioned this pull request Mar 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants