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

Segfault with readline #15344

Open
matej21 opened this issue Nov 22, 2024 · 0 comments
Open

Segfault with readline #15344

matej21 opened this issue Nov 22, 2024 · 0 comments
Assignees
Labels
confirmed bug We can reproduce this issue crash An issue that could cause a crash linux An issue that occurs on Linux node:readline

Comments

@matej21
Copy link

matej21 commented Nov 22, 2024

How can we reproduce the crash?

I encountered segfaults while using the Plop code generator, which internally relies on CLI tools like inquirer (for user input) or ora (progress). After running a generator, the process would hang, and pressing Enter would cause a segfault.

I've isolated the issue to readline when it's closed immediately after being created.

Minimal Reproduction Code

import readline from 'readline/promises';

const rl1 = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

const name = await rl1.question('Enter your name: ');
console.log(`Hello, ${name}!`);
rl1.close();

const rl2 = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
rl2.close();

Observations

  1. If only rl2 exists (without rl1), the process hangs but does not segfault.
  2. When both rl1 and rl2 are used, pressing Enter after the rl1 prompt results in a segfault.
  3. Wrapping the rl2.close() call in setTimeout(..., 0) prevents the segfault.

Relevant log output

Stack Trace (bun.report)

Bun v1.1.37-canary (4117af6) on linux x86_64 [AutoCommand]

Segmentation fault at address 0x0000001A

Features: Bun.stdin, Bun.stdout, dotenv, jsc, tsconfig, tsconfig_paths, tsconfig_paths

Sentry Issue: BUN-4KP

@matej21 matej21 added the crash An issue that could cause a crash label Nov 22, 2024
@github-actions github-actions bot added the linux An issue that occurs on Linux label Nov 22, 2024
@RiskyMH RiskyMH added node:readline confirmed bug We can reproduce this issue labels Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed bug We can reproduce this issue crash An issue that could cause a crash linux An issue that occurs on Linux node:readline
Projects
None yet
Development

No branches or pull requests

3 participants