oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
72.46k stars 2.6k forks source link

Worker threads crash with pure virtual function called possibly due to dotenv #7338

Open jdgriffith opened 8 months ago

jdgriffith commented 8 months ago

What version of Bun is running?

1.0.14

What platform is your computer?

Linux 5.15.0-76-generic x86_64 x86_64

What steps can reproduce the bug?

When using worker threads and processing quite a bit of data, the main process will crash. Sometimes it outputs the error attached.

What is the expected behavior?

It will continue processing data with normal info logs.

What do you see instead?

8|statisti | pure virtual method called
8|statisti |
8|statisti | Panic: A C++ exception occurred
8|statisti |
8|statisti | bun has crashed :'(
8|statisti |
8|statisti | ----- bun meta -----
8|statisti | Bun v1.0.14 (d8be3e51) Linux x64 #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023
8|statisti | Unknown: dotenv
8|statisti | Elapsed: 4177ms | User: 17430ms | Sys: 7304ms
8|statisti | RSS: 1.03GB | Peak: 1.19GB | Commit: 1.03GB | Faults: 19
8|statisti | ----- bun meta -----
8|statisti |
8|statisti | 0   0x558655cf3edb
8|statisti | 1   ???
8|statisti | 2   ???
8|statisti | 3   ???
8|statisti | 4   ???
8|statisti | 5   ???
8|statisti | 6   ???
8|statisti | 7   ???
8|statisti | 8   ???
8|statisti | 9   ???
8|statisti | 10  ???
8|statisti | 11  ???
8|statisti | 12  ???
8|statisti | 13  ???
8|statisti | 14  ???
8|statisti | 15  ???
8|statisti | 16  ???
8|statisti | 17  ???
8|statisti | 18  ???
8|statisti | 19  ???
8|statisti | 20  ???
8|statisti | 21  ???
8|statisti | 22  ???
8|statisti | 23  ???
8|statisti | 24  ???
8|statisti | 25  ???
8|statisti | 26  ???
8|statisti | 27  ???

Additional information

I initially thought this was related to some code I use for Node.js to bring in the module dotenv but that is not on the hot path for bun code. I think this might be related to the dotenv loader bun implemented using Zig.

Electroid commented 8 months ago

Thanks for reporting, could you provide some more information so we can reproduce this? A code sample?

jdgriffith commented 8 months ago

Let me see what I can do. My main project is too complex to offer up but I might be able to create a simplified public repo for the repro.

Jarred-Sumner commented 8 months ago

This is a bug with our Worker implementation which does reproduce in some of our unit tests. No need to put in work to do a reproduction. Our Worker implementation is not stable yet. We will fix it in a month probably.

jdgriffith commented 8 months ago

Thanks for the feedback @Jarred-Sumner. Saved me a bit of work 😅

I would imagine this issue is lower in priority to the bigger use cases in the web community. I understand if I have to wait a bit for this one. Thanks for being so diligent with the features and bugs.

Starstalker-awe commented 8 months ago

😓 Is there currently any other way to do multi-threaded work in JS while you chads put this on your to-do list? @Jarred-Sumner

samuelAndalon commented 4 months ago

just got bitten by this, any timeline to have workers not experimental ?, project i'm working on fully requires parallelism.

jdgriffith commented 4 months ago

I haven't seen much movement on this except for a few bug fixes (tangential items) here and there in the release notes. The team seems be very focused on the windows release so I'm not sure when they will get to it. I think those of us with this requirement might be in the minority when looking at Bun's use cases.

samuelAndalon commented 4 months ago

For real production traffic apps that do a bunch of synchronous operations I can’t see how a single process could hold, workers are a must.