Visual Studio Code Snap Crashes on Ubuntu 22.04 with "read out of range" Error
Problem Statement
Visual Studio Code installed via Snap crashes immediately on startup in Ubuntu 22.04, showing repeated [ERROR:process_memory_range.cc(75)] read out of range errors in terminal logs. This issue occurs with the May 2024 release (v1.90) and is caused by compatibility problems between VS Code's GPU acceleration features and Ubuntu's environment when using the Snap package. The crash prevents VS Code from launching, impacting developers needing reliable editor access.
Recommended Solutions
WARNING
These solutions apply specifically to Snap installations. Remove other installations with sudo snap remove code or sudo apt remove code before proceeding.
1. Add GPU Workaround Flag (Temporary Fix)
Run VS Code with the --in-process-gpu flag to disable GPU process isolation:
code --in-process-gpuTo apply this permanently to desktop shortcuts:
Copy the .desktop file locally:
bashcp /var/lib/snapd/desktop/applications/code_code.desktop ~/.local/share/applications/Edit the desktop file:
bashnano ~/.local/share/applications/code_code.desktopAdd
--in-process-gputo allExeclines (before%For%U):iniExec=env ... /snap/bin/code --in-process-gpu %FUpdate desktop database:
bashupdate-desktop-database ~/.local/share/applications
Why this works: This flag bypasses the problematic GPU process separation, eliminating the memory-range crash.
2. Revert to Stable Snap Version (One-Time Downgrade)
Revert to the last known stable version (v1.89.1):
sudo snap revert codeVerify the version after reverting:
code --version
# Should output: 1.89.1 [...]Why this works: Avoids bugs introduced in v1.90. Future Snap updates may resolve the issue – wait before re-updating.
3. Install Official .deb Package (Snap Alternative)
For a permanent non-Snap solution:
Remove the Snap version:
bashsudo snap remove codeAdd Microsoft's repository:
bashsudo apt install -y wget gpg apt-transport-https wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/vscode.gpg > /dev/null echo "deb [signed-by=/usr/share/keyrings/vscode.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.listInstall VS Code:
bashsudo apt update && sudo apt install code
Explanation and Best Practices
- GPU Workaround vs. Revert: Use
--in-process-gpuif you need v1.90 features. Revert if you prefer version stability. - .deb Installation: The most robust solution but forfeits Snap's containerization benefits.
- Expected Fix: Microsoft is aware of the issue (GitHub #212494). Monitor updates using:bash
sudo snap refresh --list
Verify Your Environment
After applying any solution, confirm functionality with:
code --verboseEnsure no ERROR:process_memory_range.cc appears in logs.