Skip to content

Commit 624a242

Browse files
sam-githubTrott
authored andcommittedNov 10, 2018
test: simplify regression test for SEGV
Test was introduced in 08a5b44 as a regression test, and has evolved since then. Simplify the test so that it doesn't rely on an undocumented argument to tls.createSecureCredentials(). See: nodejs/node-v0.x-archive#6690 Confirmation that this reworked test triggers the original bug: %) % node > process.version 'v0.10.48' > credentials = crypto.createCredentials() { context: {} } > context = credentials.context {} > notcontext = { setOptions: context.setOptions } { setOptions: [Function: setOptions] } > notcontext.setOptions() node: ../src/node_object_wrap.h:61: static T* node::ObjectWrap::Unwrap(v8::Handle<v8::Object>) [with T = node::crypto::SecureContext]: Assertion `handle->InternalFieldCount() > 0' failed. zsh: abort (core dumped) node PR-URL: #24241 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 3ffc84a commit 624a242

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎test/parallel/test-crypto.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ const tls = require('tls');
3838
const fixtures = require('../common/fixtures');
3939

4040
// Test Certificates
41-
const caPem = fixtures.readSync('test_ca.pem', 'ascii');
42-
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
4341
const certPfx = fixtures.readSync('test_cert.pfx');
44-
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
4542

4643
// 'this' safety
4744
// https://github.com/joyent/node/issues/6690
4845
assert.throws(function() {
49-
const options = { key: keyPem, cert: certPem, ca: caPem };
50-
const credentials = tls.createSecureContext(options);
46+
const credentials = tls.createSecureContext();
5147
const context = credentials.context;
52-
const notcontext = { setOptions: context.setOptions, setKey: context.setKey };
53-
tls.createSecureContext({ secureOptions: 1 }, notcontext);
48+
const notcontext = { setOptions: context.setOptions };
49+
50+
// Methods of native objects should not segfault when reassigned to a new
51+
// object and called illegally. This core dumped in 0.10 and was fixed in
52+
// 0.11.
53+
notcontext.setOptions();
5454
}, (err) => {
5555
// Throws TypeError, so there is no opensslErrorStack property.
5656
if ((err instanceof Error) &&

0 commit comments

Comments
 (0)