bun icon indicating copy to clipboard operation
bun copied to clipboard

Segmentation fault on a particular env variable with Apple Silicon

Open thomscoder opened this issue 3 years ago • 6 comments
trafficstars

Version

0.1.2

Platform

Darwin Kernel Version 21.5.0

What steps will reproduce the bug?

  • created a React App with bun create react ./react-app
  • created a .env file and put WELCOME_MESSAGE=ReactAppWithBun
  • {process.env.WELCOME_MESSAGE} in App.jsx

The bug (?) only presents with that particular env variable. Works well with every other variables I've tested.

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

All the time in React App created with bun create react

What is the expected behavior?

Correctly displaying the values of the env variables.

What do you see instead?

Segmentation fault error

SegmentationFault at 1929388152


–––– bun meta ––––
Bun v0.1.2 macOS Silicon 21.5.0
DevCommand: single_page_app_routing fast_refresh bun_bun public_folder dotenv 
Elapsed: 3372ms | User: 7ms | Sys: 16ms
RSS: 9.52MB | Peak: 9.52MB | Commit: 71.34MB | Faults: 268
–––– bun meta ––––

Additional information

Schermata 2022-07-10 alle 22 45 55

Just adding one letter at the end of the env variable everything turns to work normally Schermata 2022-07-10 alle 23 03 50

thomscoder avatar Jul 10 '22 20:07 thomscoder

After a rigorous process of hit and trial. This issue seems to appear only when the Key and the Value of the env is exactly of length 15

HarishTeens avatar Jul 11 '22 18:07 HarishTeens

Super interesting

Jarred-Sumner avatar Jul 11 '22 18:07 Jarred-Sumner

After a rigorous process of hit and trial. This issue seems to appear only when the Key and the Value of the env is exactly of length 15

I confirm. Tried with env set = HelloFromBun!!! or any other 15 characters string and it crashed with segmentation fault error.

Only in scaffolded React project. Works fine in a basic:

WELCOME_MESSAGE=HelloFromBun!!!
export default {
 port: 3000,
 fetch(request) {
   return new Response(process.env.WELCOME_MESSAGE); 
 }
}

for example

thomscoder avatar Jul 11 '22 19:07 thomscoder

I'm also getting segfault errors if there are blank lines in any .env files.

whiny-nil avatar Jul 25 '22 14:07 whiny-nil

Exactly the same issue, with .env, just containing:

NOTION_TOKEN=[REDACTED]

If the string content has a different length, it works, but not with that combination.

Johann01 avatar Sep 11 '22 16:09 Johann01

Confirming this is still an issue. Here's the reproduction:

// .env
WELCOME_MESSAGE=ReactAppWithBun
// index.js
export default {
  port: 3000,
  fetch(request) {
    return new Response(process.env.WELCOME_MESSAGE); 
  }
}

Output:

SegmentationFault at 0x753700F300000000


----- bun meta -----
Bun v0.2.2 (88ddb103) macOS Silicon 21.5.0
RunCommand: bun_bun dotenv 
Elapsed: 25ms | User: 18ms | Sys: 7ms
RSS: 20.61MB | Peak: 20.61MB | Commit: 67.11MB | Faults: 5
----- bun meta -----

Electroid avatar Nov 01 '22 23:11 Electroid

I'm not able to reproduce this as of v0.4.0+ (tested 0.4, 0.5, 0.5.7, and 0.5.8), but please leave a comment/reopen if still happening

Jarred-Sumner avatar Feb 27 '23 16:02 Jarred-Sumner