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 on large number of process spawns #1345

Closed
bwasti opened this issue Oct 18, 2022 · 3 comments
Closed

Segfault on large number of process spawns #1345

bwasti opened this issue Oct 18, 2022 · 3 comments
Labels
bug Something isn't working crash An issue that could cause a crash

Comments

@bwasti
Copy link
Contributor

bwasti commented Oct 18, 2022

Version

0.2.1

Platform

Darwin bwasti-mbp 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64

What steps will reproduce the bug?

import { spawn } from "bun";

const t0 = performance.now()
const parallel = 1000 // this number needs to be big
let procs = []
for (let i = 0; i < parallel; ++i) {
  procs.push(new Response(spawn(["bun", "wrk.ts"]).stdout).text())
}

const texts = await Promise.all(procs);
const t1 = performance.now()
console.log(`done, ${parallel} parallel executions in`, (Math.round(t1 - t0))/1e3, 'seconds')

wrk.ts is:

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
for (let i = 0; i < 20; ++i) {
  console.log(i)
  await sleep(50)
}

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

as long as parallel in the above code is somewhat unreasonably large (like 1000)

What is the expected behavior?

shouldn't segfault, but could throw an error saying "that's way too many processes to spawn"

What do you see instead?

Screen Shot 2022-10-18 at 12 05 28 PM

Additional information

No response

@bwasti bwasti added bug Something isn't working needs repro Needs an example to reproduce labels Oct 18, 2022
@Jarred-Sumner
Copy link
Collaborator

This reads like a GC bug

If you assign the return value of spawn() to a unique global does it still segfault?

@github-actions github-actions bot removed the crash label Oct 22, 2022
@Electroid Electroid added crash An issue that could cause a crash and removed needs repro Needs an example to reproduce labels Nov 3, 2022
@cirospaciari
Copy link
Collaborator

@bwasti I was not able to reproduce on >= v0.5.9, Are you still able to reproduce this issue in the current version?

@Jarred-Sumner
Copy link
Collaborator

This was fixed some time ago

If you run into it again, please leave a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash An issue that could cause a crash
Projects
None yet
Development

No branches or pull requests

4 participants