[Bug] Windows binary selection picks AVX version on non-AVX CPUs #6322

Open
opened 2026-02-16 18:03:05 -05:00 by yindo · 0 comments
Owner

Originally created by @sadnow on GitHub (Jan 15, 2026).

Originally assigned to: @rekram1-node on GitHub.

Summary

The Windows launcher script (bin/opencode) picks opencode-windows-x64 instead of opencode-windows-x64-baseline on CPUs without AVX support, causing immediate crash on startup.

Environment

  • OS: Windows 11
  • CPU: Intel/AMD without AVX (only SSE4.2)
  • opencode-ai version: 1.1.19-1.1.22 (all affected)
  • Node.js: v22.x

Error

Bun v1.3.6 (d530ed99) Windows x64 (baseline)
CPU: sse42
Features: ... no_avx2 no_avx ...

CPU lacks AVX support. Please consider upgrading to a newer CPU.
panic(main thread): Illegal instruction at address 0x7FF7132980FC
oh no: Bun has crashed.

Root Cause

The launcher script in bin/opencode uses:

const base = "opencode-" + platform + "-" + arch
// ...
for (const entry of entries) {
  if (!entry.startsWith(base)) continue
  // picks first match
}

Both opencode-windows-x64 and opencode-windows-x64-baseline match the pattern opencode-windows-x64. The first match wins, which depends on filesystem ordering (directory enumeration order).

Suggested Fix

Option A: Check AVX support before selecting binary (preferred)

// Detect AVX support and prefer baseline when not available
const hasAvx = checkCpuFeature('avx');
const preferBaseline = !hasAvx;

Option B: Prefer -baseline suffix when on Windows

// Sort entries to prefer baseline on Windows
entries.sort((a, b) => {
  const aBaseline = a.includes('-baseline');
  const bBaseline = b.includes('-baseline');
  // Prefer baseline if no AVX detected
  return preferBaseline ? (bBaseline - aBaseline) : (aBaseline - bBaseline);
});

Option C: Document OPENCODE_BIN_PATH workaround prominently

Workaround

Users can set the OPENCODE_BIN_PATH environment variable to force the baseline binary:

[System.Environment]::SetEnvironmentVariable(
  'OPENCODE_BIN_PATH',
  'C:\Users\<USERNAME>\AppData\Roaming\npm\node_modules\opencode-ai\node_modules\opencode-windows-x64-baseline\bin\opencode.exe',
  'User'
)

Impact

This affects all Windows users with older CPUs that lack AVX support (pre-2011 Intel, pre-2012 AMD). The crash occurs immediately on startup before any meaningful error message can be displayed, making it difficult to diagnose.

References

Originally created by @sadnow on GitHub (Jan 15, 2026). Originally assigned to: @rekram1-node on GitHub. ## Summary The Windows launcher script (`bin/opencode`) picks `opencode-windows-x64` instead of `opencode-windows-x64-baseline` on CPUs without AVX support, causing immediate crash on startup. ## Environment - OS: Windows 11 - CPU: Intel/AMD without AVX (only SSE4.2) - opencode-ai version: 1.1.19-1.1.22 (all affected) - Node.js: v22.x ## Error ``` Bun v1.3.6 (d530ed99) Windows x64 (baseline) CPU: sse42 Features: ... no_avx2 no_avx ... CPU lacks AVX support. Please consider upgrading to a newer CPU. panic(main thread): Illegal instruction at address 0x7FF7132980FC oh no: Bun has crashed. ``` ## Root Cause The launcher script in `bin/opencode` uses: ```javascript const base = "opencode-" + platform + "-" + arch // ... for (const entry of entries) { if (!entry.startsWith(base)) continue // picks first match } ``` Both `opencode-windows-x64` and `opencode-windows-x64-baseline` match the pattern `opencode-windows-x64`. The first match wins, which depends on filesystem ordering (directory enumeration order). ## Suggested Fix **Option A**: Check AVX support before selecting binary (preferred) ```javascript // Detect AVX support and prefer baseline when not available const hasAvx = checkCpuFeature('avx'); const preferBaseline = !hasAvx; ``` **Option B**: Prefer `-baseline` suffix when on Windows ```javascript // Sort entries to prefer baseline on Windows entries.sort((a, b) => { const aBaseline = a.includes('-baseline'); const bBaseline = b.includes('-baseline'); // Prefer baseline if no AVX detected return preferBaseline ? (bBaseline - aBaseline) : (aBaseline - bBaseline); }); ``` **Option C**: Document `OPENCODE_BIN_PATH` workaround prominently ## Workaround Users can set the `OPENCODE_BIN_PATH` environment variable to force the baseline binary: ```powershell [System.Environment]::SetEnvironmentVariable( 'OPENCODE_BIN_PATH', 'C:\Users\<USERNAME>\AppData\Roaming\npm\node_modules\opencode-ai\node_modules\opencode-windows-x64-baseline\bin\opencode.exe', 'User' ) ``` ## Impact This affects all Windows users with older CPUs that lack AVX support (pre-2011 Intel, pre-2012 AMD). The crash occurs immediately on startup before any meaningful error message can be displayed, making it difficult to diagnose. ## References - Related Bun issue: The crash is in Bun runtime, but the binary selection logic is in OpenCode - Discovered via oh-my-opencode fork: https://github.com/sadnow/oh-my-opencode
yindo added the windows label 2026-02-16 18:03:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6322