Skip to content

Node crashes for corner case with streams / readline #12152

Closed
@rgrannell1

Description

@rgrannell1
  • version: v7.8.0
  • platform: Linux ryan-XPS-13-9360 4.4.0-71-generic #92-Ubuntu SMP Fri Mar 24 12:59:01 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • subsystem: stream, readline
  • minimal failing example:
require('readline').createInterface({
	input:    process.stdin,
	output:   require('stream').Writable({
		write: (chunk, encoding, callback) => {
		    process.stdout.write('broken', encoding);
			callback( )
		}
	}),
	terminal: true
}).question('this will fail', _ => { })

I wish I could explain why this code fails, but I'm not entirely sure. At a glance it looks like a type-error occurs in V8 due to a missing check for the buffer-type in Node.js:

/usr/bin/nodejs[27737]: ../src/stream_base.cc:192:int node::StreamBase::WriteBuffer(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `Buffer::HasInstance(args[1])' failed.
 1: node::Abort() [node]
 2: node::Assert(char const* const (*) [4]) [node]
 3: node::StreamBase::WriteBuffer(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 4: void node::StreamBase::JSMethod<node::StreamWrap, &node::StreamBase::WriteBuffer>(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 5: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
 6: 0xabfbed [node]
 7: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
 8: 0x1264281843a7

If you need any more details let me know

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Issues and PRs that require attention from people who are familiar with C++.streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions