[BUG] WebAssembly memory allocation error with --dangerously-skip-permissions after kernel update

Resolved 💬 3 comments Opened Aug 1, 2025 by croakingtoad Closed Aug 15, 2025

● ## Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.65
  • Operating System: Ubuntu 22.04 LTS
  • Terminal: SSH session

## Bug Description
Claude Code with --dangerously-skip-permissions flag attempts to allocate 10GB of
virtual memory for WebAssembly, which exceeds both WebAssembly's 4GB limit and typical
user virtual memory limits. This causes the application to fail with "Out of memory"
errors for users with virtual memory restrictions.

## Steps to Reproduce

  1. Set a virtual memory limit for a non-root user: ulimit -v 5242880 (5GB)
  2. Install Claude Code globally: sudo npm install -g @anthropic-ai/claude-code
  3. Run as the limited user: claude --dangerously-skip-permissions
  4. Observe WebAssembly memory allocation error

## Expected Behavior
Claude Code should start normally with --dangerously-skip-permissions flag and
respect reasonable memory limits (WebAssembly maximum is 4GB).

## Actual Behavior
Claude Code crashes with the following error when user has virtual memory limits:
node:internal/deps/undici/undici:5829
return await WebAssembly.instantiate(mod, {
^

RangeError: WebAssembly.instantiate(): Out of memory: Cannot allocate Wasm memory for
new instance
at lazyllhttp (node:internal/deps/undici/undici:5829:32)

Node.js v20.19.4

## Additional Context
System Details:

  • Node.js: v20.19.4
  • npm: 10.2.4
  • Memory: 16GB RAM + 6GB Swap (mostly unused)

Root Cause - strace reveals excessive allocation:
mmap(NULL, 10737479680, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) =
-1 ENOMEM (Cannot allocate memory)
The --dangerously-skip-permissions flag causes an attempt to allocate 10GB
(10737479680 bytes)
of virtual memory, which is:

  • 2.5x larger than WebAssembly's maximum capacity (4GB / 65536 pages)
  • Larger than many systems' default user virtual memory limits

Tested scenarios:

  • claude as root user (unlimited virtual memory) - Works
  • claude --dangerously-skip-permissions as root user (unlimited virtual memory) -

Works

  • claude as limited user (5GB virtual memory limit) - Works
  • claude --dangerously-skip-permissions as limited user (5GB virtual memory

limit) - Fails

  • claude --dangerously-skip-permissions as user with unlimited virtual memory -

Works

Why this matters:

  1. Many Linux distributions set default virtual memory limits for non-root users
  2. The 10GB allocation is unnecessary and exceeds WebAssembly's actual capabilities
  3. Users shouldn't need to remove system security limits to run Claude Code

Workaround:
Remove virtual memory limits for affected users by adding to
/etc/security/limits.d/:
username soft as unlimited
username hard as unlimited
Then log out and back in.

Related Issues:

  • Similar to #144 (WebAssembly memory allocation error in SLURM environment)

Suggested Fix:
The --dangerously-skip-permissions flag should not affect WebAssembly memory
allocation size. The allocation should stay within WebAssembly's 4GB limit regardless
of permission settings.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗