Skip to content

SIGSEGV in libcrypto.so when https.request is called #1156

Closed
@brunohadlich

Description

@brunohadlich
  • Node.js Version:
    v6.12.3
  • OS:
    Linux coordinator 4.9.79-yocto-standard Update README for help #1 SMP PREEMPT Sun Feb 25 00:21:42 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Scope (install, code, runtime, meta, other?):
  • Module (and version) (if relevant):
    https

I have an application running behind apache and apache only accepts https requests, my problem is that when a request is received I have to make a https request to another server in order to obtain the response and then return such response to the browser, the moment that I execute a https.request call I get a SIGSEGV. I won't be able to provide a piece of code that anyone can run and reproduce because this problem happens only when I run the entire application but I executed node with valgrind and it seems that the problem is coming from libcrypto.so, I think that maybe this is a concurrency issue in libcrypto.so but I'm not sure, the valgrind output is:

==6646== Use of uninitialised value of size 8
==6646== at 0x1B53F4223073: ???
==6646== by 0x1B53F458DA12: ???
==6646== by 0x1B53F421C7D4: ???
==6646== by 0x1B53F458D29B: ???
==6646== by 0x1B53F421C7D4: ???
==6646== by 0x1B53F458C21E: ???
==6646== by 0x1B53F4589EBA: ???
==6646== by 0x1B53F45847E6: ???
==6646== by 0x1B53F421E7B1: ???
==6646== by 0x1B53F45828AC: ???
==6646== by 0x1B53F45820A1: ???
==6646== by 0x1B53F4578F87: ???
==6646==
==6646== Invalid read of size 8
==6646== at 0x3A0E78F4F3: CRYPTO_set_ex_data (in /usr/lib/libcrypto.so.1.0.0)
==6646== by 0xCAF3E4: node::crypto::SecureContext::Init(v8::FunctionCallbackInfov8::Value const&) (in /usr/bin/node)
==6646== by 0x6303C3: v8::internal::FunctionCallbackArguments::Call(void ()(v8::FunctionCallbackInfov8::Value const&)) (in /usr/bin/node)
==6646== by 0x671522: ??? (in /usr/bin/node)
==6646== by 0x671B38: ??? (in /usr/bin/node)
==6646== by 0x671C04: ??? (in /usr/bin/node)
==6646== by 0x1B53F42060C6: ???
==6646== by 0x1B53F4591493: ???
==6646== by 0x1B53F421E7B1: ???
==6646== by 0x1B53F458FB08: ???
==6646== by 0x1B53F421C7D4: ???
==6646== by 0x1B53F458DF5A: ???
==6646== Address 0xd0 is not stack'd, malloc'd or (recently) free'd
==6646==
==6646==
==6646== Process terminating with default action of signal 11 (SIGSEGV)
==6646== Access not within mapped region at address 0xD0
==6646== at 0x3A0E78F4F3: CRYPTO_set_ex_data (in /usr/lib/libcrypto.so.1.0.0)
==6646== by 0xCAF3E4: node::crypto::SecureContext::Init(v8::FunctionCallbackInfov8::Value const&) (in /usr/bin/node)
==6646== by 0x6303C3: v8::internal::FunctionCallbackArguments::Call(void (
)(v8::FunctionCallbackInfov8::Value const&)) (in /usr/bin/node)
==6646== by 0x671522: ??? (in /usr/bin/node)
==6646== by 0x671B38: ??? (in /usr/bin/node)
==6646== by 0x671C04: ??? (in /usr/bin/node)
==6646== by 0x1B53F42060C6: ???
==6646== by 0x1B53F4591493: ???
==6646== by 0x1B53F421E7B1: ???
==6646== by 0x1B53F458FB08: ???
==6646== by 0x1B53F421C7D4: ???
==6646== by 0x1B53F458DF5A: ???
==6646== If you believe this happened as a result of a stack
==6646== overflow in your program's main thread (unlikely but
==6646== possible), you can try to increase the size of the
==6646== main thread stack using the --main-stacksize= flag.
==6646== The main thread stack size used in this run was 8388608.

As I said before I could not create a simple script that could reproduce the issue but I'm making a https request like:

var payload = JSON.stringify({"key":"value"});
var options = {
	hostname: '192.168.15.14',
	port: 443,
	path: '/path',
	method: 'POST',
	headers: {
		'Content-Type': 'application/json',
		'Content-Length': Buffer.byteLength(payload)
	}
};
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var req_remote_outlets = https.request(options, function(res) {
		res.on("error", (error) => {
				console.log(error);
		});
		res.on("data", (chunk) => {
				console.log(chunk.toString("utf8"));
		});
		res.on("end", () => {
		});
});
req_remote_outlets.on("error", (err) => {
		console.log(err);
});
req_remote_outlets.write(payload);
req_remote_outlets.end();

I didn't find any source in the web that could help me with such issue, please tell me if I'm doing something wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions