Skip to content

TLSSocket.prependOnceListener('session') results in an abort #38135

@zyscoder

Description

@zyscoder

What steps will reproduce the bug?

Setup a node instance,

» node

and run the following javascript code.

tlsSocket = tls.connect('r','\u{85}');
tlsSocket.prependOnceListener('session',(session)=>{});

Then an abort occurs.
This PoC is very similar to #38133, but the core dump traces and the behaviors of nodejs are different. I think it's worth analyzing for both of them.

How often does it reproduce? Is there a required condition?

This problem can always be triggered following the steps above.

What is the expected behavior?

If any error occurs, an exception or other similar error-reporting stuff should be thrown. There is no reason to abort the whole node process.

What do you see instead?

» node
Welcome to Node.js v14.15.1.
Type ".help" for more information.
> tlsSocket = tls.connect('r','\u{85}');
<ref *1> TLSSocket {
...
}
> Uncaught:
<ref *1> Error: connect ENOENT r
...
}
> tlsSocket.prependOnceListener('session',(session)=>{});
node[225836]: ../src/tls_wrap.cc:938:static void node::TLSWrap::EnableSessionCallbacks(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `(wrap->ssl_) != nullptr' failed.
 1: 0xa03530 node::Abort() [node]
 2: 0xa035ae  [node]
 3: 0xb44f2a  [node]
 4: 0xbe369b  [node]
 5: 0xbe4c46  [node]
 6: 0xbe52c6 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
 7: 0x13ff259  [node]
[1]    225836 abort (core dumped)  node

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.tlsIssues and PRs related to the tls subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions