Bun throws "Illegal instruction (core dumped)"

Hi,

I’m trying NixOS inside VirtualBox on two separate instances, one built from the ISO and the other from the VirtualBox demo/demo, both fresh installs and I love it. But.

The main machine is running Win10 and Bun works as intended inside WSL2, so we can normally cast out the “CPU argument” (AMD Ryzen 3 2200G with Radeon Vega Graphics 3.50 GHz) I saw on StackOverflow. If it works on Win/WSL it should work in Nix.

So. When adding Bun to configuration.nix or installing it from nix-shell -p bun …it installs, then throw “Illegal instruction” when invoked.

Is there anything I can add to the config file to make it work as intended?

I think this is a Bun issue: https://github.com/search?q=repo%3Aoven-sh%2Fbun+Illegal+instruction&type=issues

Also of note 169 issues on seg faults https://github.com/search?q=repo%3Aoven-sh%2Fbun+segfault&type=issues

Improve stability is their top priority according to the above.

Thank you for taking time to answer. Unfortunately, I think I’ve done the same research and already went trough the Bun’s issues github and StackOverflow … even there, the main reason cited was the CPU being old or not having something Bun use. If the hardware was indeed at fault it should fail the same on WSL, as it use the same machine.

I’m trying NixOS inside VirtualBox on two separate instances

I guess the important question is not what your Ryzen 3 2200 is capable of, but rather what your virtualized CPU is capable of.

Edit: If you want to do a 1-on-1 comparison, try cat /proc/cpuinfo | less and check what CPU flags are available, both in WSL2 (I hope that’s possible?) and inside the VM. Not sure which one might be missing though, but maybe the error message told you something more?

1 Like

Now this, is interesting.

Inside WSL:
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave osxsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw wdt topoext fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni

Inside NixOS VM
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch ssbd vmmcall fsgsbase bmi1 bmi2 rdseed clflushopt arat

What’s on WSL but not the VM:
pdpe1gb
fma
xsave osxsave avx f16c
osvw wdt topoext fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap
sha_ni

What is added to VM:
constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid tsc_known_freq
ssbd vmmcall fsgsbase bmi1 bmi2 rdseed
arat

On that tool, it highlights the differences but the link will last for only 24h.

I am not sure either, but is it possible that the missing avx and avx2 flags are responsible?

If you will have a look at this: Bun v0.1.6 | Bun Blog

bun appears to have a baseline build that does not require AVX/AVX2 on the CPU. But that means that the normal build most likely requires them. And your VM doesn’t have them. And nixpkgs might not have them either.

So I’d say best bet is to teach your virtualized CPU AVX/AVX2, which should be doable.

I’ll try that one.

It’s anyway almost out of curiosity. I went on with making VM’s because I was struggling to install Nix into WSL in the first place.

I already have my “usual dev environement setup” so I’m not into emergency mode, but intrigued and pleased by NixOS’s way of doing things.