bun
bun copied to clipboard
"Illegal instruction" when using bun:sqlite with bun canary on Debian 11 VPS
What version of Bun is running?
0.4.1 (270b07e85e82b46491cc713fb2a5bb973d3de4f6)
What platform is your computer?
Linux 5.10.0-20-amd64 x86_64 unknown
What steps can reproduce the bug?
When using bun:sqlite
on the canary build (270b07e85e82b46491cc713fb2a5bb973d3de4f6), the code just quits with the error Illegal instruction
.
The code I tried to test it with is taken from the documentation of bun:sqlite
(at the Example
section).
Though, here's the code:
import { Database } from "bun:sqlite";
const db = new Database("mydb.sqlite");
db.run(
"CREATE TABLE IF NOT EXISTS foo (id INTEGER PRIMARY KEY AUTOINCREMENT, greeting TEXT)",
);
db.run("INSERT INTO foo (greeting) VALUES (?)", "Welcome to bun!");
db.run("INSERT INTO foo (greeting) VALUES (?)", "Hello World!");
// get the first row
db.query("SELECT * FROM foo").get();
// { id: 1, greeting: "Welcome to bun!" }
// get all rows
db.query("SELECT * FROM foo").all();
// [
// { id: 1, greeting: "Welcome to bun!" },
// { id: 2, greeting: "Hello World!" },
// ]
// get all rows matching a condition
db.query("SELECT * FROM foo WHERE greeting = ?").all("Welcome to bun!");
// [
// { id: 1, greeting: "Welcome to bun!" },
// ]
// get first row matching a named condition
db.query("SELECT * FROM foo WHERE greeting = $greeting").get({
$greeting: "Welcome to bun!",
});
// [
// { id: 1, greeting: "Welcome to bun!" },
// ]
What is the expected behavior?
I expect bun to successfully run the code and execute the SQL commands without an error (or maybe a more precise error if it's my fault/an issue specific on my end).
What do you see instead?
Given the example code, running it with bun run sqlite.ts
quits with the error Illegal instruction
and nothing more.

Additional information
Running the exact same code with the exact same bun version (0.4.1 -> 270b07e85e82b46491cc713fb2a5bb973d3de4f6) on macOS (Darwin 22.2.0 arm64 arm
) does not throw any error and successfully executes the code.
As Illegal instruction
sounds like some CPU instruction thing for me (though I'm not experienced with that stuff), here's some output I think could help:
lscpu
output:
07:08:53 root@debian Core ±|main ✗|→ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 40 bits physical, 48 bits virtual
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 8
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 15
Model: 6
Model name: Common KVM processor
Stepping: 1
CPU MHz: 2799.998
BogoMIPS: 5599.99
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 256 KiB
L1i cache: 256 KiB
L2 cache: 32 MiB
L3 cache: 16 MiB
NUMA node0 CPU(s): 0-7
Vulnerability Itlb multihit: KVM: Mitigation: VMX unsupported
Vulnerability L1tf: Mitigation; PTE Inversion
Vulnerability Mds: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Unknown: No mitigations
Vulnerability Retbleed: Not affected
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
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 l
m constant_tsc nopl xtopology cpuid tsc_known_freq pni cx16 x2apic hypervisor lahf_lm cpuid_fault pti
fastfetch
(host key):
KVM/QEMU Standard PC (i440FX + PIIX, 1996) pc-i440fx-7.0
Unfortunately, I couldn't find more details about the CPU used by my hosting provider, but if you require more information from me, please tell me! The (rough) specs of my VPS are:
- CPU with virtual cores (
kvm64
, yeah that's obviously not the CPU name) - 24GB RAM
- 120GB SSD
Also please let me know if this is my fault/an issue specific on my end!
You'll need the baseline build it seems, run curl https://bun.sh/install | bash
on there
Oh I forgot to mention that, I'm sorry: I already tried to run it with the baseline build and it successfully ran, but I can't wait for 0.4.1 to release, because of the node:dns
support and I already need to test something with the proxy configuration on my VPS. But well, I'll wait then. Thank you for your fast responses though <3 Literally, I'm amazed by how fast you always respond, thanks 🫶
Seems like I have to reopen this, because it still fails on the baseline, or am I doing something wrong?
Thanks for opening this issue!
Hey @Jarred-Sumner, :) I'm also getting this, it seems reproducible even with your fork of drizzle-bun https://github.com/Jarred-Sumner/drizzle-bun which I presume at least worked on bun when you forked this.
Thanks for opening this issue!
Hey @Jarred-Sumner, :) I'm also getting this, it seems reproducible even with your fork of drizzle-bun https://github.com/Jarred-Sumner/drizzle-bun which I presume at least worked on bun when you forked this.
Actually, I just pulled this on my mac, and it works fine. :D. My home machine was running it with WSL with an amd 5800x cpu
EDIT:
Here is my lscpu output (using WSL also) where I see illegal instruction as I too in both repo's that failed was using bun:sqlite
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 48 bits physical, 48 bits virtual
CPU(s): 6
On-line CPU(s) list: 0-5
Thread(s) per core: 2
Core(s) per socket: 3
Socket(s): 1
Vendor ID: AuthenticAMD
CPU family: 25
Model: 33
Model name: AMD Ryzen 7 5800X 8-Core Processor
Stepping: 0
CPU MHz: 3800.024
BogoMIPS: 7600.04
Virtualization: AMD-V
Hypervisor vendor: Microsoft
Virtualization type: full
L1d cache: 96 KiB
L1i cache: 96 KiB
L2 cache: 1.5 MiB
L3 cache: 32 MiB
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
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 constant_tsc rep_good nopl tsc_reliable nonstop_tsc c
puid extd_apicid pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfct
r_core ssbd ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr arat npt nrip_save tsc_scale vmcb
_clean flushbyasid decodeassists pausefilter pfthreshold v_vmsave_vmload umip vaes vpclmulqdq rdpid fsrm
Hi. Ran into this issue with an i7-4790K machine. It just started happening since 4-5 days ago. bun eats the remaining free disk space whenever I run a sqlite query through a POST request with Bun.serve()
Fixed in https://github.com/oven-sh/bun/commit/b7c96bfaae1d5c49cbebdfe5fcd3befacbfaede4
Once CI is 🟢, run
bun upgrade --canary
Please leave a comment if it's still happening or regresses