Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSStream ReadStream Assertion Failure #3970

Closed
Havvy opened this issue Nov 22, 2015 · 4 comments
Closed

JSStream ReadStream Assertion Failure #3970

Havvy opened this issue Nov 22, 2015 · 4 comments
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. tls Issues and PRs related to the tls subsystem.

Comments

@Havvy
Copy link
Contributor

Havvy commented Nov 22, 2015

Minimal test case:

"use strict";

const NetSocket = require("net").Socket;
const tls = require("tls");
const netSocket = new NetSocket();
netSocket.setEncoding("utf-8");
const tlsSocket = tls.connect({socket: netSocket, rejectUnauthorized: false, isServer: false});
netSocket.connect({port: 6697, host: "irc.freenode.net"});

Results in:

node: ../src/js_stream.cc:180: static void node::JSStream::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `Buffer::HasInstance(args[0])' failed.

Note that the setEncoding call is the crucial bit.

@mscdex mscdex added tls Issues and PRs related to the tls subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. labels Nov 22, 2015
@trevnorris trevnorris changed the title node: ../src/js_stream.cc:180: static void node::JSStream::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `Buffer::HasInstance(args[0])' failed. JSStream ReadStream Assertion Failure Nov 23, 2015
@trevnorris
Copy link
Contributor

/cc @indutny

@indutny
Copy link
Member

indutny commented Nov 25, 2015

Will look into it tomorrow.

@indutny
Copy link
Member

indutny commented Nov 25, 2015

The fix is here, but you won't be happy with it. Basically, TLS can't be established on connection after .setEncoding(), because the most of the data is lost during conversion to the utf-8.

But it should not segfault on this, so it is still kind of a bugfix.

@Havvy
Copy link
Contributor Author

Havvy commented Nov 26, 2015

Yeah, I knew it was /wrong/, and I am indeed not happy, but that's my problem, not yours.

Your (where you = Node.js) problem is the segfault.

indutny added a commit to indutny/io.js that referenced this issue Dec 5, 2015
If `.setEncoding` was called on input stream - all emitted `data` will
be `String`s instances, not `Buffer`s. This is unacceptable for
`StreamWrap`, and should not lead to the crash.

Fix: nodejs#3970
@indutny indutny closed this as completed in de2fd63 Dec 7, 2015
indutny added a commit that referenced this issue Dec 8, 2015
If `.setEncoding` was called on input stream - all emitted `data` will
be `String`s instances, not `Buffer`s. This is unacceptable for
`StreamWrap`, and should not lead to the crash.

Fix: #3970
PR-URL: #4031
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
indutny added a commit that referenced this issue Dec 15, 2015
If `.setEncoding` was called on input stream - all emitted `data` will
be `String`s instances, not `Buffer`s. This is unacceptable for
`StreamWrap`, and should not lead to the crash.

Fix: #3970
PR-URL: #4031
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
indutny added a commit that referenced this issue Dec 17, 2015
If `.setEncoding` was called on input stream - all emitted `data` will
be `String`s instances, not `Buffer`s. This is unacceptable for
`StreamWrap`, and should not lead to the crash.

Fix: #3970
PR-URL: #4031
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
indutny added a commit that referenced this issue Dec 23, 2015
If `.setEncoding` was called on input stream - all emitted `data` will
be `String`s instances, not `Buffer`s. This is unacceptable for
`StreamWrap`, and should not lead to the crash.

Fix: #3970
PR-URL: #4031
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
scovetta pushed a commit to scovetta/node that referenced this issue Apr 2, 2016
If `.setEncoding` was called on input stream - all emitted `data` will
be `String`s instances, not `Buffer`s. This is unacceptable for
`StreamWrap`, and should not lead to the crash.

Fix: nodejs#3970
PR-URL: nodejs#4031
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants