Skip to content

Segmentation fault when window is resized #4291

Closed
@anseki

Description

@anseki

The process throws "Segmentation fault" if an user resize a window when a script is waiting for user input via TTY, after it accesses to process.stdout.

For example:

var
  fs = require('fs'),
  bufferSize = 1024,
  buffer = new Buffer(bufferSize),
  readSize,
  chunk;

readSize = fs.readSync(fs.openSync('/dev/tty', 'r'), buffer, 0, bufferSize);
chunk = buffer.toString('utf8', 0, readSize);

console.log('INPUT: ' + chunk);

This code above works fine without error.

foo
INPUT: foo

But, if process.stdout is accessed:

var
  fs = require('fs'),
  bufferSize = 1024,
  buffer = new Buffer(bufferSize),
  readSize,
  chunk;

process.stdout; // access to property

readSize = fs.readSync(fs.openSync('/dev/tty', 'r'), buffer, 0, bufferSize);
chunk = buffer.toString('utf8', 0, readSize);

console.log('INPUT: ' + chunk);

If a window is resized when the script is waiting for user input, it throws "Segmentation fault".

I tried this code in some versions, and it seems that this issue occurs in v3.3.0+.
v3.2.0 is OK.
v3.3.0 makes this issue occur.

Is this a problem of libuv v1.7.3 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Issues and PRs that require attention from people who are familiar with C++.libuvIssues and PRs related to the libuv dependency or the uv binding.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions