Repository navigation
segfault in TLS #1696
Description
Reproduces 100% of the time within a minute of running the server. Server opens multiple TLS client connections (as a client).
I'll gladly help with testing a fix or sharing some of the backtrace data, but cannot share server code or specific scenario.
Please see nodejs/node-v0.x-archive#8780, I'm not 100% sure but I think it may be the same issue. I'm unable to reproduce it in node 0.12.2 (server is running fine, the segfault doesn't happen).
Backtrace (commit 7693705):
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000000000069eed0 in SSL_read ()
(gdb) backtrace
#0 0x000000000069eed0 in SSL_read ()
#1 0x0000000000d40a39 in node::TLSWrap::ClearOut() ()
#2 0x0000000000d4117e in node::TLSWrap::OnReadImpl(long, uv_buf_t const*, uv_handle_type, void*) ()
#3 0x0000000000ce109b in node::JSStream::ReadBuffer(v8::FunctionCallbackInfo<v8::Value> const&) ()
#4 0x0000000000850002 in v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) ()
#5 0x000000000087721b in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()
#6 0x00002307b4e060bb in ?? ()
#7 0x00003c26fce690f9 in ?? ()
#8 0x00002307b4e06001 in ?? ()
#9 0x00007ffe6b7e47f0 in ?? ()
#10 0x00007ffe6b7e4850 in ?? ()
#11 0x00002307b4e99739 in ?? ()
#12 0x00002bb54efbee61 in ?? ()
#13 0x00003c26fce6b669 in ?? ()
...
dmesg:
segfault at 30 ip 000000000069eed0 sp 00007ffe6b7e41a8 error 4 in iojs[400000+d0e000]
Although nodejs/node-v0.x-archive#8780 contains a suggested fix, I don't see that it was applied in node.js 0.12.2, so either something else fixed it or the situation is different.
Naively applying the fix suggested in 8780 on io.js 2.0.1 (18d457b) doesn't seem to help. Instead I'm failing on an assertion.
"Fix" (tls_wrap.cc):
if (wrap->enc_out_) {
NodeBIO::FromBIO(wrap->enc_out_)->Read(nullptr, wrap->write_size_);
// Ensure that the progress will be made and `InvokeQueued` will be called.
wrap->ClearIn();
}
Backtrace with fix applied:
Program terminated with signal SIGABRT, Aborted.
#0 0x00007fc17f768cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) backtrace
#0 0x00007fc17f768cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007fc17f76c0d8 in __GI_abort () at abort.c:89
#2 0x00007fc17f761b86 in __assert_fail_base (fmt=0x7fc17f8b2830 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0xf7d1f9 "(bio->ptr) != (nullptr)", file=file@entry=0xf7d1e0 "../src/node_crypto_bio.h", line=line@entry=77,
function=function@entry=0xf7e080 <_ZZN4node7NodeBIO7FromBIOEP6bio_stE19__PRETTY_FUNCTION__> "static node::NodeBIO* node::NodeBIO::FromBIO(BIO*)") at assert.c:92
#3 0x00007fc17f761c32 in __GI___assert_fail (assertion=0xf7d1f9 "(bio->ptr) != (nullptr)", file=0xf7d1e0 "../src/node_crypto_bio.h", line=77,
function=0xf7e080 <_ZZN4node7NodeBIO7FromBIOEP6bio_stE19__PRETTY_FUNCTION__> "static node::NodeBIO* node::NodeBIO::FromBIO(BIO*)") at assert.c:101
#4 0x0000000000673989 in node::NodeBIO::FromBIO(bio_st*) [clone .isra.22] [clone .part.23] ()
#5 0x0000000000d409bf in node::TLSWrap::EncOutCb(node::WriteWrap*, int) ()
#6 0x0000000000850002 in v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) ()
#7 0x000000000087721b in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()
#8 0x00003993517060bb in ?? ()
#9 0x00007fff1da78730 in ?? ()
#10 0x0000399351706001 in ?? ()
#11 0x00007fff1da78710 in ?? ()
#12 0x00007fff1da78778 in ?? ()
#13 0x0000399351a8292c in ?? ()
#14 0x00001507279beb79 in ?? ()
#15 0x0000000000000000 in ?? ()
Activity
EricTheOne commentedon May 13, 2015
@indutny
tls: emit errors on close whilst async action
indutny commentedon May 14, 2015
May I ask you to give a try to the following patch #1702 ?
EricTheOne commentedon May 14, 2015
@indutny gladly and thanks for the quick response. Applied the patch on io.js master (4e2f999), still getting segfault:
EricTheOne commentedon May 14, 2015
By the way, as I was testing the patch npm seemed to fail installing four different modules.
I'm running
configure && make && make installon the io.js repo, anything I'm missing to get npm to work?tls: prevent use-after-free
EricTheOne commentedon May 26, 2015
@indutny I've tested the changes on 2.1.0 as well, still segfaults:
Any way I can help with more info?
indutny commentedon May 26, 2015
@EricTheOne I commented about it on other issue. I really need a test case that reproduces the problem. It doesn't look like I fully understand the problem atm.
tls: emit errors on close whilst async action
tls: prevent use-after-free
tls: emit errors on close whilst async action
tls: prevent use-after-free
tls: emit errors on close whilst async action
tls: prevent use-after-free
indutny commentedon Jun 6, 2015
@EricTheOne PTAL at #1910, I think it should fix the issue for you ;)
_stream_wrap: prevent use after free in TLS
_stream_wrap: prevent use after free in TLS
Fishrock123 commentedon Jul 7, 2015
Ala #1910 (comment), @EricTheOne did that patch fix this issue? :)
_stream_wrap: prevent use after free in TLS
Fishrock123 commentedon Jul 24, 2015
I'm going to assume it did. Please re-open if it didn't.