GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tls: emit errors on close whilst async action by indutny · Pull Request #1702 · nodejs/node

Conversation

@indutny

@indutny indutny commented May 14, 2015

Copy link
Copy Markdown
Member

When loading session, OCSP response, SNI, always check that the
self._handle is present. If it is not - the socket was closed - and we
should emit the error instead of throwing an uncaught exception.

Fix: nodejs/node-v0.x-archive#8780
Fix: #1696

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced May 14, 2015
segfault in TLS #1696
Closed
Segfault node v0.11.14 related to TLS nodejs/node-v0.x-archive#8780
Closed
@indutny

indutny commented May 14, 2015

Copy link
Copy Markdown
Member Author

cc @iojs/crypto

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@migounette

migounette commented May 14, 2015

Copy link
Copy Markdown

@indutny You fixed at the JS part by checking the _handle, but what I found during an intensive play with TLS is that the _encout was NULL (a C++ level). It is a kind of SSL Close issue race condition (for me), but I need to change the test case because it's very difficult for me to reproduce.

Thanks for the fix

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mscdex mscdex added the tls Issues and PRs related to the tls subsystem. label May 14, 2015
@indutny

indutny commented May 18, 2015

Copy link
Copy Markdown
Member Author

@migounette @EricTheOne: I have updated the PR, please take a look

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@EricTheOne

EricTheOne commented May 19, 2015

Copy link
Copy Markdown

@indutny thanks, applied both patches in order on v2.0.2, getting a segfault elsewhere (maybe it's progress):

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000d18d00 in node::StreamBase::EmitData(long, v8::Local<v8::Object>, v8::Local<v8::Object>) ()
(gdb) bt
#0  0x0000000000d18d00 in node::StreamBase::EmitData(long, v8::Local<v8::Object>, v8::Local<v8::Object>) ()
#1  0x0000000000d3cc8a in node::TLSWrap::OnReadSelf(long, uv_buf_t const*, uv_handle_type, void*) ()
#2  0x0000000000d40d19 in node::TLSWrap::OnReadImpl(long, uv_buf_t const*, uv_handle_type, void*) ()
#3  0x000000000084fa02 in v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) ()
#4  0x0000000000876c1b in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented May 19, 2015

Copy link
Copy Markdown
Member Author

@EricTheOne pushed one more commit, PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@EricTheOne

EricTheOne commented May 19, 2015

Copy link
Copy Markdown

@indutny I've applied all three commits in order, on v2.0.2. Getting a different segfault now:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000000030f1490 in ?? ()
(gdb) bt
#0  0x00000000030f1490 in ?? ()
#1  0x0000000000d40d29 in node::TLSWrap::OnReadImpl(long, uv_buf_t const*, uv_handle_type, void*) ()
#2  0x000000000084fa02 in v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) ()
#3  0x0000000000876c1b in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented May 22, 2015

Copy link
Copy Markdown
Member Author

@EricTheOne looks like I don't fully understand problem yet. Any way I can reproduce it locally?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented May 29, 2015

Copy link
Copy Markdown
Member Author

Just a heads up, @evanlucas discovered a crash in a test: https://gist.github.com/evanlucas/6ab0a62ebe7ffa5d0ddf

It is reproducible after patching the test suite:

diff --git a/test/parallel/test-tls-js-stream.js b/test/parallel/test-tls-js-stream.js
index e156f44..292bd4f 100644
--- a/test/parallel/test-tls-js-stream.js
+++ b/test/parallel/test-tls-js-stream.js
@@ -61,6 +61,7 @@ var server = tls.createServer({

     socket.end('hello');
     socket.resume();
+    socket.destroy();
   });

   socket.once('close', function() {

Going to investigate it in detail later.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny
indutny force-pushed the fix/gh-node-8780 branch from a9e9b9a to ad3a799 Compare May 29, 2015 18:28
@indutny

indutny commented May 29, 2015

Copy link
Copy Markdown
Member Author

@evanlucas and it is actually fixed by this commit ad3a799

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented May 29, 2015

Copy link
Copy Markdown
Member Author

Erm, not by commit, rather by this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@evanlucas

evanlucas commented May 29, 2015

Copy link
Copy Markdown
Contributor

yay!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented May 29, 2015

Copy link
Copy Markdown
Member Author

Which is kind of sad for the @EricTheOne's thing...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented May 29, 2015

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

indutny added 3 commits June 1, 2015 18:34
@indutny
tls: emit errors on close whilst async action
c359ada
When loading session, OCSP response, SNI, always check that the
`self._handle` is present. If it is not - the socket was closed - and we
should emit the error instead of throwing an uncaught exception.

Fix: nodejs/node-v0.x-archive#8780
Fix: nodejs#1696
@indutny
tls: prevent use-after-free
c0f4ddf
* Destroy `SSL*` and friends on a next tick to make sure that we are not
  doing it in one of the OpenSSL callbacks
* Add more checks to the C++ methods that might be invoked during
  destructor's pending queue cleanup

Fix: nodejs/node-v0.x-archive#8780
Fix: nodejs#1696
@indutny
tls_wrap: invoke queued callbacks in DestroySSL
3533378
@indutny
indutny force-pushed the fix/gh-node-8780 branch from ad3a799 to 3533378 Compare June 1, 2015 16:38
@indutny

indutny commented Jun 1, 2015

Copy link
Copy Markdown
Member Author

@migounette @EricTheOne any news? ;)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Jun 1, 2015

Copy link
Copy Markdown
Member Author

CI (with style fixes): https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/747/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Jun 1, 2015

Copy link
Copy Markdown
Member Author

CI is green.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis
bnoordhuis force-pushed the master branch from 311c3e4 to b926718 Compare June 2, 2015 17:25
@trevnorris

trevnorris commented Jun 4, 2015

Copy link
Copy Markdown
Contributor

@indutny going to merge this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@indutny

indutny commented Jun 4, 2015

Copy link
Copy Markdown
Member Author

Yeah, let's land it. @trevnorris LGTY?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jun 4, 2015

Copy link
Copy Markdown
Contributor

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

indutny added a commit that referenced this pull request Jun 4, 2015
@indutny
tls: emit errors on close whilst async action
5795e83
When loading session, OCSP response, SNI, always check that the
`self._handle` is present. If it is not - the socket was closed - and we
should emit the error instead of throwing an uncaught exception.

Fix: nodejs/node-v0.x-archive#8780
Fix: #1696
PR-URL: #1702
Reviewed-By: Trevor Norris <[email protected]>
indutny added a commit that referenced this pull request Jun 4, 2015
@indutny
tls: prevent use-after-free
75930bb
* Destroy `SSL*` and friends on a next tick to make sure that we are not
  doing it in one of the OpenSSL callbacks
* Add more checks to the C++ methods that might be invoked during
  destructor's pending queue cleanup

Fix: nodejs/node-v0.x-archive#8780
Fix: #1696
PR-URL: #1702
Reviewed-By: Trevor Norris <[email protected]>
indutny added a commit that referenced this pull request Jun 4, 2015
@indutny
tls_wrap: invoke queued callbacks in DestroySSL
59d9734
PR-URL: #1702
Reviewed-By: Trevor Norris <[email protected]>
@indutny

indutny commented Jun 4, 2015

Copy link
Copy Markdown
Member Author

Landed in 5795e83, 75930bb, and 59d9734. Thank you!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rvagg rvagg mentioned this pull request Jun 11, 2015
Release proposal: 2.3.0 #1939
Closed
@brendanashworth brendanashworth closed this Jun 21, 2015
@indutny
indutny deleted the fix/gh-node-8780 branch June 21, 2015 01:49
thefourtheye
thefourtheye reviewed Jun 21, 2015
View reviewed changes
Comment thread src/tls_wrap.cc Outdated

@thefourtheye thefourtheye Jun 21, 2015

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Not sure if the error message sounds like a TypeError

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@indutny indutny Jun 28, 2015

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yeah, I think it is worth submitting a follow-up fix PR. ;)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@thefourtheye thefourtheye Jun 28, 2015

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@indutny I feel that the default types of Errors is not enough. We should at least have something like ValueError. What do you think?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@indutny indutny Jun 28, 2015

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd say it might be too expensive to create them in C++, unless I'm missing something obvious.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@thefourtheye thefourtheye Jun 28, 2015

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I locally created a patch which fixes all the inconsistent error messages like this, in the js files. And I had an internal/errors.js file which defined ValueError. Looks like that solves most of the wrong data error messages. But I am not sure if it is worthy introducing a new Error type.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@indutny indutny Jun 28, 2015

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yeah, I don't think anyone really checks the type of error. It kind of serves only an informational purpose when it pops up in the stderr.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

tls Issues and PRs related to the tls subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

segfault in TLS Segfault node v0.11.14 related to TLS

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@indutny @migounette @EricTheOne @evanlucas @trevnorris @thefourtheye @mscdex @brendanashworth
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.